Changeset 368
- Timestamp:
- 06/18/2001 07:14:29 AM (8 years ago)
- Files:
-
- 1 modified
-
eddie/trunk/bin/eddie.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
eddie/trunk/bin/eddie.py
r361 r368 1 #!/ usr/local/bin/python2 ## 1 #!/opt/python2/bin/python 2 ## 3 3 ## File : eddie.py 4 4 ## … … 98 98 config.loadExtraDirectives(os.path.join(commonlibdir, "Directives")) 99 99 100 # Start Stop the Main threads 100 101 101 def start_threads(sargs, cargs): 102 global sthread 103 global cthread 104 105 please_die.clear() 102 """Start any support threads that are required. 103 Currently these are: 104 - Scheduler thread: schedules directives to run 105 - Console Server thread: handles connections to console port 106 """ 107 108 please_die.clear() # reset thread signal 109 110 global sthread # the Scheduler thread 106 111 sthread = threading.Thread(group=None, target=scheduler, name='Scheduler', args=sargs, kwargs={}) 107 sthread.start() # start it up 108 109 cthread = threading.Thread(group=None, target=sockets.console_server_thread, name='Console', args=cargs, kwargs={}) 110 cthread.start() 112 sthread.start() # start the thread running 113 114 global cthread # the Console Server thread 115 if config.consport > 0: # don't start if CONSPORT=0 116 cthread = threading.Thread(group=None, target=sockets.console_server_thread, name='Console', args=cargs, kwargs={}) 117 cthread.start() 111 118 112 119 return() 113 120 121 114 122 def stop_threads(): 115 please_die.set() 116 sthread.join() 117 cthread.join() 123 """Stop any threads started by start_threads(). 124 """ 125 126 please_die.set() # signal threads to die 127 128 sthread.join() # wait for schedular thread to die 129 130 if config.consport > 0: # console thread not running if CONSPORT=0 131 cthread.join() # wait for console thread to die 118 132 119 133 return() 134 120 135 121 # Exit Eddie cleanly122 136 def eddieexit(): 137 """Exit Eddie cleanly. 138 """ 139 123 140 log.log( '<eddie>eddieexit(), Eddie exiting cleanly.', 3 ) 124 141 # email admin any remaining messages … … 404 421 start_threads(sargs,cargs) 405 422 406 while 1:423 while not please_die.isSet(): 407 424 try: 408 425 ### Perform housecleaning duties … … 441 458 log.sendadminlog() 442 459 443 time.sleep(10*60) # sleep for 10 minutes between housekeeping duties 460 #time.sleep(10*60) # sleep for 10 minutes between housekeeping duties 461 please_die.wait(10*60) # sleep for 10 minutes between housekeeping duties 462 # or until all threads signalled to exit 444 463 445 464 except KeyboardInterrupt: … … 447 466 log.log( '<eddie>main(), KeyboardInterrupt encountered - quitting', 1 ) 448 467 print "\nEddie quitting ... bye bye" 449 break 450 451 452 # Save history (debug.. FS only for now...) 453 #history.eddieHistory.save('FS',directive.dlist) 454 455 # sleep for set period - only quits with CTRL-c 456 #log.log( '<eddie>main(), sleeping for %d secs' % (config.scanperiod), 6 ) 457 458 # Sleep by setting SIGALRM to go off in scanperiod seconds 459 #time.sleep( config.scanperiod ) 460 #signal.alarm( config.scanperiod ) 461 #signal.pause() 468 eddieexit() 469 470 471 log.log( '<eddie>main(), main thread signalled to die - exiting', 1 ) 472 eddieexit() 473 462 474 463 475
