FAQ
Not exactly a Python question, but I thought I would start here.

I have a server that runs as a daemon. I can restart the server manually
with the command

myserver restart

This command starts a new myserver which first looks up the pid for the one
that is running and sends it a terminate signal. The new one then
daemonizes itself.

I want the server to be able to restart itself. Will it work to have
myserver issue "myserver restart" using os.system? I fear that the new
myserver, which will be running in a subshell, will terminate the subshell
along with the old myserver when it sends the terminate signal to the old
myserver. If so, what is the correct way to restart the daemon? Will it
work to run the restart command in a subprocess rather than a subshell or
will a subprocess also terminate when its parent terminates?
--
Jeffrey Barish

Search Discussions

  • Albert Hopkins at Apr 26, 2011 at 1:04 pm

    On Tue, 2011-04-26 at 06:13 -0600, Jeffrey Barish wrote:
    Not exactly a Python question, but I thought I would start here.

    I have a server that runs as a daemon. I can restart the server manually
    with the command

    myserver restart

    This command starts a new myserver which first looks up the pid for the one
    that is running and sends it a terminate signal. The new one then
    daemonizes itself.

    I want the server to be able to restart itself. Will it work to have
    myserver issue "myserver restart" using os.system? I fear that the new
    myserver, which will be running in a subshell, will terminate the subshell
    along with the old myserver when it sends the terminate signal to the old
    myserver. If so, what is the correct way to restart the daemon? Will it
    work to run the restart command in a subprocess rather than a subshell or
    will a subprocess also terminate when its parent terminates?
    You should look into tools like daemon-tools, or similar. It already
    solves this (and many other) problems.

    -a
  • Chris Angelico at Apr 26, 2011 at 7:38 pm

    On Tue, Apr 26, 2011 at 10:13 PM, Jeffrey Barish wrote:
    Not exactly a Python question, but I thought I would start here.

    I have a server that runs as a daemon. ?I can restart the server manually
    with the command

    myserver restart

    This command starts a new myserver which first looks up the pid for the one
    that is running and sends it a terminate signal. ?The new one then
    daemonizes itself.
    What job manager do you have? Can you set up a script in /etc/init.d
    or /etc/init and then use that to restart the daemon? Upstart scripts
    can be managed with the 'initctl' command, for instance.

    Chris Angelico

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 26, '11 at 12:13p
activeApr 26, '11 at 7:38p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase