I am trying to start an Python application on a Debian based OS that is running on a router. This application comes prebundled with site-packages and a python binary. Like a virtual environment. The application is rather big (a webserver) so I don't think there is a point in posting it here.

I have created an init.d script to launch the application on boot. The same script I have already used on other devices for the exact same application and on these devices it was working. Unfortunatly on the router it does not and I have spent the whole day finding out why - but am now giving up and asking a question here.

I have minimized the init script to a bare minimum which looks as follows


# Provides:             Webserver
# Required-Start:       $local_fs $remote_fs $syslog
# Required-Stop:        $local_fs $remote_fs $syslog
# Should-Start:         $network
# Should-Stop:          $network
# Default-Start:        2 3 4 5
# Default-Stop:
# Short-Description:    ...
# Description:          ...

/path/to/python /path/to/main.py /path/to/configfile &

exit 0

The original script was a lot more extensive than this. But it think this should do (?).

I created symlinks in the correct rc*.d directories through

update-rc.d webserver defaults

I verified that they were actually created and they were.

After a reboot nothing happens. The application won't be started. If I run the script in a terminal it starts as it should.

I have tried redirecting the output of the command to a log file. The file will be created but is empty. So I don't whether some error occures by starting it on boot.

Just for testing I have replaced the command to start the application with a simple infinite shell (and python) script that prints something every second. Both scripts were running after I have rebooted the machine.

I have looked through all log files (there arent many) in /var/log but can't find any reference point to why the application fails to start. And since the log file to which I redirect the output is empty I don't know what may fail. But the log file definitely gets created after I have removed it. So the command is actually run.

What else can I try to find the error?


After still searching for the answer I have found a possible solution that I tryed right away on the router. It was said, that if an application comes with a python binary it may be a virtual environment and prior to starting the application I should run the script activate that can be found in that environment. Unfortunatly there is no activate coming with that webserver.

  • Try adding some debug logging to the start of your /path/to/main.py. – Ferenc Wágner Mar 4 '16 at 10:29

Your Answer

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

Browse other questions tagged or ask your own question.