[Erp5-report] r11435 - /erp5/trunk/utils/oood/start.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Nov 22 14:33:28 CET 2006
Author: kevin
Date: Wed Nov 22 14:33:26 2006
New Revision: 11435
URL: http://svn.erp5.org?rev=11435&view=rev
Log:
Rename methods for consistency.
Add consistent logs.
Modified:
erp5/trunk/utils/oood/start.py
Modified: erp5/trunk/utils/oood/start.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/start.py?rev=11435&r1=11434&r2=11435&view=diff
==============================================================================
--- erp5/trunk/utils/oood/start.py (original)
+++ erp5/trunk/utils/oood/start.py Wed Nov 22 14:33:26 2006
@@ -101,17 +101,18 @@
_l("Was not running or didn't exist, so no need to kill", i, 0)
-def startAll():
- lib.log("Pool - Start all %s instances" % config.pool_size, 0)
- stopAll()
+def initPool():
+ lib.log("Pool - Initialize: populate the pool with %s instances" % config.pool_size, 0)
+ flushPool()
for i in range(config.pool_size):
startInstance(i)
+ lib.log("Pool - Wait %s seconds to let the instance #%s start" % (config.instance_load_time, i), 0)
time.sleep(config.instance_load_time)
- lib.log("Pool - All %s instances started" % config.pool_size, 0)
+ lib.log("Pool - Initialized: %s instances started" % config.pool_size, 0)
-def stopAll():
- lib.log("Pool - Stop all instances", 0)
+def flushPool():
+ lib.log("Pool - Flush requested: kill all instances", 1)
# pool_size can change dynamiccaly, so clear every running OOo intance
max_pool_size = config.pool_size
for pid_file in glob.glob('%s*' % config.pid_dir):
@@ -123,31 +124,31 @@
max_pool_size = old_pool_size
for i in range(max_pool_size):
killInstance(i)
- lib.log("Pool - All instances flushed away", 0)
+ lib.log("Pool - Flushed: all instances killed", 0)
-def showStatus():
+def showPoolStatus():
"""
Show Pool details and statistics.
"""
# TODO: dynamic verbose message
- print "Pool:"
- print " * Status: %s" % 'Started' #(stopped)
- print " * Size: %s" % config.pool_size
- print " * Uptime: %s" % 'unknown'
- print " * OOo instance running: %s" % config.pool_size
- print " * OOo instance stopped: %s" % 0
- print " * OOo instance automaticcaly restarted: %s" % 0
+ print "===== Pool Statistics ====="
+ print "Status: %s" % 'Started' #(stopped)
+ print "Size: %s" % config.pool_size
+ print "Uptime: %s" % 'unknown'
+ print "OOo instances running: %s" % config.pool_size
+ print "OOo instances stopped: %s" % 0
+ print "OOo instances automaticcaly restarted since launch: %s" % 0
def usage():
print """Usage: %s [options]
-i, --init
- Kill all previous OOo instances in the pool (if any) and re-populate it.
+ Initialize the pool: kill all previous OOo instances (if any) and re-populate the pool.
-f, --flush
- Kill all OOo instances in the pool.
+ Flush the pool: kill all OOo instances to empty the pool.
-s, --status, --stat
- Show Pool statistics and status.
+ Show pool statistics and status.
-h, --help
Show this screen.
""" % sys.argv[0]
@@ -162,26 +163,26 @@
usage()
sys.exit(2)
- # Start action according parameters
- for o, a in opts:
- if o in ("-h", "--help"):
- usage()
- sys.exit(0)
- if o in ("-i", "--init"):
- startAll()
- sys.exit(0)
- if o in ("-f", "--flush"):
- stopAll()
- sys.exit(0)
- if o in ("-s", "--status", "--stat"):
- showStatus()
- sys.exit(0)
-
# Check args number
if len(opts) == 0:
usage()
# Exit on command line error
sys.exit(2)
+ # Start action according parameters
+ for o, a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ sys.exit(0)
+ elif o in ("-i", "--init"):
+ initPool()
+ sys.exit(0)
+ elif o in ("-f", "--flush"):
+ flushPool()
+ sys.exit(0)
+ elif o in ("-s", "--status", "--stat"):
+ showPoolStatus()
+ sys.exit(0)
+
# Exit on general error
sys.exit(1)
More information about the Erp5-report
mailing list