1

I have a simple python script which I want to start a daemon-service in background in docker container

/sbin/start-stop-daemon --start  --user root --make-pidfile --pidfile /var/lock/subsys/my-application.pid --exec 'python /opt/app/uc/monitor/bin/my-application.py'

when I execute this command in a shell I get

/sbin/start-stop-daemon: unable to stat //python /opt/app/uc/monitor/bin/my-application.py (No such file or directory)

However when execute just the below command in shell it works

python /opt/app/uc/monitor/bin/my-application.py 

I'm sure the python is installed and all the links have been setup.

Thanks for the help

RichVel
  • 3,992
  • 4
  • 24
  • 38
Dave
  • 726
  • 3
  • 14
  • 36
  • Docker is not a virtual machine. There is no upstart, and therefore no start-stop-daemons. Checkout runit or supervisor if you must. Or you could stick to the one process/one container 'best practice'. – user2105103 Dec 15 '16 at 21:14
  • I figured that and created a launcher script ... – Dave Dec 16 '16 at 19:25

1 Answers1

1

That error message implies that start-stop-daemon is looking for a file to open (the stat operation is a check before it opens the file) and treating your 'python ... ' argument as if it was a file.

See this example which confirms this. You may need to read the man page for start-stop-daemon, for your Ubuntu version, to check what a valid command would be for your setup.

Simplest solution is probably to create a shell script (say /opt/app/uc/monitor/bin/run-my-application.sh), and put this into it:

#!/bin/bash
python /opt/app/uc/monitor/bin/my-application.py

Be sure to do chmod +x on this file. If python is not found, use which python to find the path to python and use that in the script.

Now try:

/sbin/start-stop-daemon --start  --user root --make-pidfile --pidfile /var/lock/subsys/my-application.pid --exec '/opt/app/uc/monitor/bin/run-my-application.sh'
RichVel
  • 3,992
  • 4
  • 24
  • 38