Restart application automatically on KILL - objective-c

I am developing an application on MAC OS . It needs to run continously i.e. if someone kills it , it has to restart on its own . I found a similar behavior in the Finder application in MAC. How can I implement this ???
Currently, I am using launchctl for this purpose but I am facing some problems with permissions and communication

launchctl is the way to do it. In order to get it set up, you need to understand about authorization services. The Authorization Services Programming Guide is a good place to start.

Related

wpa_supplicant - run without sudo

I'm developing an embedded linux application & it uses egt as the GUI front-end. The GUI uses wpa_supplicant to connect/ register WiFi network. I've got the same GUI application running on my desktop for development purposes.
Accessing wpa_supplicant (e.g. wpa_ctrl_open) isn't an issue on the actual embedded device as it runs as root, but on the desktop I'm running into permission errors. I don't want to run the GUI application as root on my desktop in case it trashes my system.
So whats the proper way to run wpa_supplicant as non-root?
Many thanks,
All credit goes to Klaus D. for the correct answer. As he suggested the issue as the permissions on the sockets. Initially I only changed the permission of the actual socket (i.e. WiFi interface) but the actual containing folder needs to be set correctly also (i.e. var/run/supplicant).
Thanks Klaus & hope this helps someone else.

cPanel : Running an application

I am trying to build a middleware application ( you know...retrive data from a webservice and store to db in cPAnel and send the data to the webservice hosted from here)
Is it possible to run an application in cPanel?
If it is possible what is the prefferedlanguage for this purpose and
why?
If I am trying to run an application which has to update this fetch
hourly automatically form code.is it possible.means i want this
application to be in running state for an indefinite time.Is it
possible?
My thoughts are:
1. cPanel is not a jumping off point for applications. It is simply a shared hosting management console. It gives you the ability to do some management. You can fire off applications by making a cronjob.
Generally you have two choices, you can use shell scripting or PHP invoked from a shell.
Now this narrows it down further. PHP is configured to have a maximum execution time to stop people hogging the processors.
If you are going to write some proper middleware, I'd suggest that you either get yourself an Amazon, Jelastic or some other cloud hosting provider. You will get the ability to deploy a real application, on a full operating system - rather than "hacking" a solution.
cPanel based installs are really for those people who just want to put a website, whack up a blog, or do some low bandwidth hosting. Running something constantly is going to have you violate the terms of service on these accounts very quickly.

how to notify user when glassfish is down

I am using Glassfish v3.0.1 for my project. However, Glassfish seems to be down many times. Therefore, I want to develop a mechanism that notifies me whenever Glassfish is down. Is there any option in Glassfish? If not, how can I achieve this? Further, how can I understand why Glassfish goes down? I cannot find proper explanations in logs.
I'm not aware of any options in Glassfish itself and I doubt there are any (it's usually hard for a process to know when it's dead :-). Write a script that tries to connect to the service (for example, using wget or curl) or use a system monitoring tool that watches processes.
To find out why Glassfish terminates, you must debug the problem. Here are some tipps:
Add/enable more logging
Search the source code for System.exit(). This can terminate an Java app without any trace of why it happens. (this might help, too)
Check the standard output of the process
Look for crash dumps; see the documentation of the Java VM which you're using.

How do I disable the network connection from .NET without needing admin privileges?

I may be SOL on this but I thought I would give throw it out for possible solutions.
I am writing a computer access control service to help me control my kids' computer use. Plan on open sourcing it when I have it working. It is written in VB.Net and needs to work on XP through 7.
I am running into all sorts of security and desktop access issues on Windows 7. The service needs to run as admin to execute the NetSh command to disable the network. But I cannot interact with the desktop from the service so I IPC to a UI to handle other stuff, but I still cannot detect from the service if the desktop is locked. Argghh!
I could get it all working from a hidden windows form app if I could just lick the one piece that needs admin permissions: disabling the network.
It does no good if a kid logs on and denies the popup asking if the program should run as administrator and he says no. Also windows 7 will not start a program set to run as admin using
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Anyone know how to get this working? Or have an outside the box solution?
I wish I could provide some references, but I'm failing at my google-fu right now... but I'm pretty sure UAC doesn't apply to services. If you implement your program as a windows service application instead of a (hidden) windows forms application, and set it up to run for your kids' user accounts and not your own, that should work.
UPDATE
Found this on google, haven't played with it at all. Looks sound though... basically, CreateProcessAsUser to run the forms app from your service app that's running as administrator.

Best methodology for developing c# long running processor apps

I have several different c# worker applications that run various continuous tasks: sending emails from queue, importing new orders from website database to orders database, making database backups and restores, running data processing for OLTP -> OLAP, and other related tasks. Before, I released these as windows services, but currently I release them as regular console applications. They are all based on a common task runner framework I created, and I am happy with that, however I am not sure what is the best way to deploy these types of applications. I like the console version because it is quick and easy, and it is possible to quickly see program activity and output. The downside is that the worker computer has several console screens running and it gets messy. On the other hand the service method seems to take to long to deploy and I have to go through event logs to see messages. What are some experiences/comments on this?
I like the console app approach. I typically have things set up so I can pass a switch like -unattended that suppresses the console screen.
Windows Service would be a good choice, it runs in the background no matter if you close current session, also you can configure it to start automatically after windows restart when performing a patches update on the server. You can log important messages to event viewer or database table.
For a thing like this, the standard way of doing it is with Windows services. You want the service to run on the network account so it won't require a logged in user.
I worked on something a few years ago that had similar issues. Logically I needed a service, but sometimes I needed to see what was going on and generally I wanted a history. So I developed a service which did the work, any time it wanted to log, it called to it's subscribers (implemented as an observer pattern).
The service registered it's own data logger (writing to a database) and at run time, the user could run a GUI which connected to the service using remoting to become a live listener!
I'm going to vote for Windows Services. It's going to get to be a real pain managing those console applications.
Windows Service deployment is easy: after the initial install, you just turn them off and do an XCOPY. No need to run any complicated installers. It's only semi-complicated the first time, and even then it's just
installutil MyApp.exe
Configre the services to run under a domain account for the best security and easiest interop with other machines.
Use a combination of event logs (with Error, Warning, and Information) for important notifications, and just dump verbose logging to a text file.
Why not get the best of all worlds and use something like:
http://topshelf-project.com/
It will allow you to run your program as command line or a windows service.
I'm not sure if this applies to your applications or not, but when I have some console applications that are not dependent on user input or they are the kind of applications that just do their job and quit, I run such programs on a virtual server, this way I don't see a screen popping up when I'm working, and virtual servers are easy to create and restart.
We regularly use windows services as the background processes. I don't like command-line apps as you need to be logged into the server for them to run. Services run in the background all the time (assuming they're auto-start). They're also trivial to install w/the sc.exe command-line tool that's in windows. I like it better than the bloat-ware that is installutil.exe. Of course installutil does more, but I don't need what it does. I just want to register my service.
We've also created a infrastructure where we have a generic service .exe that loads .DLLs based on an interface definition, so adding a new "service" is as simple as dropping in a new DLL and restarting the service host.
However, we started to move away from services. The problem we have with them is that they lock up the DLLs (for obvious reasons) so it's a pain to upgrade them. We need to stop, upgrade and then restart. Not hard, but additional steps. Instead we're moving to special "pages" in our asp.net apps that run the actual background jobs we need done. There's still a service, but all it does it invoke the asp.net pages so it doesn't lock up any of our DLLs. Then we can replace the DLLs in the asp.net bin directory and normal asp.net rules for app-domain restart kick in.