Hi i just discoverd ubuntu upstart (etc/init/* scripts). And i would like to use it to run a particular application. This app is run via a command line, but there is an argument to start an instance of the app and another argument to stop it (let say 'start' and 'stop') Is there a way to use upstart for that ??
|
|
It should be as simple as creating a file
You should then be able to do See this for some more info: http://upstart.at/ |
|||||||||||
|
|
If all you want to do is start/stop the service at boot time.. then drop your script in /etc/init.d and run
Or if that complains
Both of which will add it to the bootup/shutdown. Note that this means it will run as root.. so you may want to make sure the script switches users to your user or another one that you want this program running as. Upstart is meant to replace such scripts if at all possible. The motivations for this are faster boot and a more clear encoding of the information needed to know when to start/stop a service. It achieves the faster boot specifically by only having to read the contents of /etc/init to get started, which is especially beneficial when you add in ureadahead to the boot process, as the less random tiny script files ureadahead has to cache, the more it can spend time on important things like libraries and programs needed to start the system up. I'd bet that the script you're running does a few things to setup the environment, then runs the program in a daemonized mode. Your upstart job should seek to replace the script's logic, not just run the script. |
|||
|
|
I guess you'll want it to start or stop on different events, so it'll be easier to set up two different jobs. If the same events toggles your app, then you could set up a job with a script that checks wether it's running or not, and hence starts or stops your app. |
|||
