2

I am trying to create a process to be automatically started and maintained by Ubuntu's upstart (Ubuntu 12.04). I have been looking at this page as well as on this page and I am aware of the upstart cookbook and upstart stanzas. Using especially the information from the first two likes, I did the following to incorporate such a process. First, I created a file /etc/init/testservice.conf with the following content:

# myservice - myservice job file

description "my service description"
author "Me <myself@i.com>"

# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn

# When to start the service
start on runlevel [2345]

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
respawn

# Essentially lets upstart know the process will detach itself to the background
#expect fork

chdir /home/user/testcode

# Start the process
exec python mycommand.py

with some simple dummy python code mycommand.py residing in the directory /home/user/testcode. Checking with initctl list or ps I see that the command is not yet running. Therefore, I tried to start it 'manually' according to this page with

start testservice

which produced the following output

start: Rejected send message, 1 matched rules; type="method_call", sender=":1.88" (uid=1000 pid=9103 comm="start testservice ) interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" estination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")

but did not start the process mycommand.py.

What am I doing wrong? How to tell ubuntu and/or upstart to run the command?

Alex
  • 5,700
  • Not exactly a duplicate. I cannot find the answer on how to start the process on the fly. Do I, for example, need to reboot the entire system to start the processes? If so, this is the solution. But I prefer a command line solution. – Alex Jul 24 '13 at 16:13
  • 1
    Run your command with sudo. sudo start testservice. – slm Jul 24 '13 at 16:28
  • Oh great. I expected it to be something really stupid and trivial. And the error message did not really help, if it is related anyway. Thanks a lot – Alex Jul 24 '13 at 16:30

0 Answers0