Skip to content

Commit

Permalink
Make logreopen also reopen the transcript log (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Apr 15, 2015
1 parent 96cc4a3 commit 0b95470
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Change log
3.0.0 due to lack of tests):
https://github.com/zopefoundation/zdaemon/issues/10.

- Make ``logreopen`` also reopen the transcript log:
https://github.com/zopefoundation/zdaemon/issues/9.

- Fix race condition where ``stop`` would be ignored if the daemon
manager was waiting before respawning a crashed program.
https://github.com/zopefoundation/zdaemon/issues/13.
Expand Down
8 changes: 8 additions & 0 deletions src/zdaemon/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,25 @@ def test_logreopen():
... '''
... <runner>
... program sleep 100
... transcript transcript.log
... </runner>
... ''')
>>> system("./zdaemon -Cconf start")
. .
daemon process started, pid=1234
>>> os.rename('transcript.log', 'transcript.log.1')
>>> system("./zdaemon -Cconf logreopen")
kill(1234, 12)
signal SIGUSR2 sent to process 1234
This also reopens the transcript.log:
>>> sorted(os.listdir('.'))
['conf', 'transcript.log', 'transcript.log.1', 'zdaemon', 'zdsock']
>>> system("./zdaemon -Cconf stop")
. .
daemon process stopped
Expand Down
1 change: 1 addition & 0 deletions src/zdaemon/tests/testzdctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def doctest_ZDCmd_help():
>>> run("help logreopen")
logreopen -- Send a SIGUSR2 signal to the daemon process.
This is designed to reopen the log file.
Also reopens the transcript log file.
>>> run("help logtail")
logtail [logfile] -- Run tail -f on the given logfile.
Expand Down
2 changes: 2 additions & 0 deletions src/zdaemon/zdctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,13 @@ def help_show(self):
print("show all -- show all of the above")

def do_logreopen(self, arg):
self.do_reopen_transcript('')
self.do_kill('USR2')

def help_logreopen(self):
print("logreopen -- Send a SIGUSR2 signal to the daemon process.")
print(" This is designed to reopen the log file.")
print(" Also reopens the transcript log file.")

def do_logtail(self, arg):
if not arg:
Expand Down

0 comments on commit 0b95470

Please sign in to comment.