The program works when started by cron or from the shell. But when started by upstart, it seems to loop indefinitely.

The scripts and the files they use are in the /home/user/ directory, and are owned by user, and all have 777 permissions.

The upstart .conf file:

start on runlevel [2345]
stop on runlevel [!2345]

kill signal SIGHUP
# reload signal SIGHUP

exec python /home/user/Documents/init.py -b 600

upstart executes commands as root by default. But the user can be specified: How do I start jobs as a non privileged user in Upstart?.

But the script was programmed with user specific variables and a dependency to a specific directory.

init.py had this line:

self.d_root = os.path.join(os.path.expanduser('~'),'Documents','records')

I changed it to this and it worked:

self.d_root = os.path.dirname(os.path.realpath(__file__))

But I think the proper fix is to add this line to the .conf file:

setuid = user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.