0

I have a python daemon that runs on linux. I'm implementing an auto updating functionality which works this way:

  1. When new version is detected, the app invokes updater script using subprocess.call.
  2. Child process (which is updater script in reality) stops the daemon
  3. Because the daemon is stopped, updater script also terminates :/

So my question is how can I launch updater script in a way that it won't depend on parent process. In other words, I don't want parent process termination to cause child process termination.

Environment: Linux mint 16

Python 3.3

Thanks

Davita
  • 8,928
  • 14
  • 67
  • 119
  • Have a look at http://stackoverflow.com/questions/473620/how-do-you-create-a-daemon-in-python and https://pypi.python.org/pypi/daemonize/. – Christian Berendt Jun 22 '14 at 19:44

1 Answers1

1

You could do something along the lines of:

from subprocess import Popen

updater = ['/usr/bin/python', '{PATH TO}/updater_script.py', '&']
Popen(updater)

The updater won't be affected by the deamon closing.

cchristelis
  • 1,985
  • 1
  • 13
  • 17
  • Thanks but it didn't work. child process is terminated when parent is stopped :( – Davita Jun 22 '14 at 20:42
  • I have updated my answer to something that might work... it is looking a little hacky but it might be worth a shot. – cchristelis Jun 23 '14 at 07:18
  • I tried that too. It didn't help either. The only way I found was to daemonize the child process. It's a bit of overhead for a simple task, but it works. Thanks anyway – Davita Jun 23 '14 at 08:59
  • I'm glad you found a solution, oddly enough the approach I posted worked on a test program... – cchristelis Jun 23 '14 at 09:01