Commit 2e5b4381 authored by Michel Pelletier's avatar Michel Pelletier

activites can be commented out sanely now

parent 397227fe
...@@ -105,7 +105,7 @@ TODO ...@@ -105,7 +105,7 @@ TODO
""" """
import os, sys, time import os, sys, time, signal
SOFTWARE_HOME = '/projects/users/zs_zope' SOFTWARE_HOME = '/projects/users/zs_zope'
START_FILE = os.path.join(SOFTWARE_HOME, 'ZServer', 'start.py') START_FILE = os.path.join(SOFTWARE_HOME, 'ZServer', 'start.py')
...@@ -125,7 +125,11 @@ class ForkError: ...@@ -125,7 +125,11 @@ class ForkError:
pass pass
FORK_ATTEMPTS = 2 FORK_ATTEMPTS = 2
BEAT_DELAY = 1
# This is the number of seconds between the parent pulsing the child.
# Set to 0 to deactivate pulsing.
BEAT_DELAY = 0
VERBOSE = 1 VERBOSE = 1
# If you want the parent to 'pulse' Zope every 'BEAT_DELAY' seconds, # If you want the parent to 'pulse' Zope every 'BEAT_DELAY' seconds,
...@@ -137,8 +141,8 @@ VERBOSE = 1 ...@@ -137,8 +141,8 @@ VERBOSE = 1
# username and password may be None if the method does not require # username and password may be None if the method does not require
# authentication. # authentication.
activities = (('http://localhost:9222/Heart/heart', 'michel', '123'), # activities = (('http://localhost:9222/Heart/heart', 'michel', '123'),
) # )
def pstamp(message): def pstamp(message):
...@@ -146,6 +150,7 @@ def pstamp(message): ...@@ -146,6 +150,7 @@ def pstamp(message):
def heartbeat(): def heartbeat():
print 'tha-thump' print 'tha-thump'
if activities:
for a in activities: for a in activities:
try: try:
result = ZPublisher.Client.call(a[0], a[1], a[2]) result = ZPublisher.Client.call(a[0], a[1], a[2])
...@@ -187,6 +192,9 @@ def main(): ...@@ -187,6 +192,9 @@ def main():
pf.write(("%s" % os.getpid())) pf.write(("%s" % os.getpid()))
pf.close() pf.close()
while 1: while 1:
if not BEAT_DELAY:
p,s = os.waitpid(pid, 0)
else:
p,s = os.waitpid(pid, os.WNOHANG) p,s = os.waitpid(pid, os.WNOHANG)
if not p: if not p:
time.sleep(BEAT_DELAY) time.sleep(BEAT_DELAY)
...@@ -218,3 +226,10 @@ def main(): ...@@ -218,3 +226,10 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()
...@@ -105,7 +105,7 @@ TODO ...@@ -105,7 +105,7 @@ TODO
""" """
import os, sys, time import os, sys, time, signal
SOFTWARE_HOME = '/projects/users/zs_zope' SOFTWARE_HOME = '/projects/users/zs_zope'
START_FILE = os.path.join(SOFTWARE_HOME, 'ZServer', 'start.py') START_FILE = os.path.join(SOFTWARE_HOME, 'ZServer', 'start.py')
...@@ -125,7 +125,11 @@ class ForkError: ...@@ -125,7 +125,11 @@ class ForkError:
pass pass
FORK_ATTEMPTS = 2 FORK_ATTEMPTS = 2
BEAT_DELAY = 1
# This is the number of seconds between the parent pulsing the child.
# Set to 0 to deactivate pulsing.
BEAT_DELAY = 0
VERBOSE = 1 VERBOSE = 1
# If you want the parent to 'pulse' Zope every 'BEAT_DELAY' seconds, # If you want the parent to 'pulse' Zope every 'BEAT_DELAY' seconds,
...@@ -137,8 +141,8 @@ VERBOSE = 1 ...@@ -137,8 +141,8 @@ VERBOSE = 1
# username and password may be None if the method does not require # username and password may be None if the method does not require
# authentication. # authentication.
activities = (('http://localhost:9222/Heart/heart', 'michel', '123'), # activities = (('http://localhost:9222/Heart/heart', 'michel', '123'),
) # )
def pstamp(message): def pstamp(message):
...@@ -146,6 +150,7 @@ def pstamp(message): ...@@ -146,6 +150,7 @@ def pstamp(message):
def heartbeat(): def heartbeat():
print 'tha-thump' print 'tha-thump'
if activities:
for a in activities: for a in activities:
try: try:
result = ZPublisher.Client.call(a[0], a[1], a[2]) result = ZPublisher.Client.call(a[0], a[1], a[2])
...@@ -187,6 +192,9 @@ def main(): ...@@ -187,6 +192,9 @@ def main():
pf.write(("%s" % os.getpid())) pf.write(("%s" % os.getpid()))
pf.close() pf.close()
while 1: while 1:
if not BEAT_DELAY:
p,s = os.waitpid(pid, 0)
else:
p,s = os.waitpid(pid, os.WNOHANG) p,s = os.waitpid(pid, os.WNOHANG)
if not p: if not p:
time.sleep(BEAT_DELAY) time.sleep(BEAT_DELAY)
...@@ -218,3 +226,10 @@ def main(): ...@@ -218,3 +226,10 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment