default to non-daemon mode
This commit is contained in:
parent
e8ac790b1f
commit
e201d6baf9
@ -48,6 +48,13 @@ def create_options(parser):
|
|||||||
"""
|
"""
|
||||||
config.add_common_options(parser)
|
config.add_common_options(parser)
|
||||||
config.add_log_options(parser)
|
config.add_log_options(parser)
|
||||||
|
parser.add_option("-D", "--daemon", default=False, dest="daemon",
|
||||||
|
action="store_true",
|
||||||
|
help="Run as a long-running process. When not "
|
||||||
|
"specified (the default) run the scrub "
|
||||||
|
"operation once and then exits. When specified "
|
||||||
|
"do not exit and run scrub on wakeup_time "
|
||||||
|
"interval as specified in the config file.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -56,12 +63,19 @@ if __name__ == '__main__':
|
|||||||
create_options(oparser)
|
create_options(oparser)
|
||||||
(options, args) = config.parse_options(oparser)
|
(options, args) = config.parse_options(oparser)
|
||||||
|
|
||||||
|
daemon = options.get('daemon')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conf, app = config.load_paste_app('glance-scrubber', options, args)
|
conf, app = config.load_paste_app('glance-scrubber', options, args)
|
||||||
|
|
||||||
wakeup_time = int(conf.get('wakeup_time', 300))
|
if daemon:
|
||||||
server = scrubber.Daemon(wakeup_time)
|
wakeup_time = int(conf.get('wakeup_time', 300))
|
||||||
server.start(app)
|
server = scrubber.Daemon(wakeup_time)
|
||||||
server.wait()
|
server.start(app)
|
||||||
|
server.wait()
|
||||||
|
else:
|
||||||
|
import eventlet
|
||||||
|
pool = eventlet.greenpool.GreenPool(1000)
|
||||||
|
scrubber = app.run(pool)
|
||||||
except RuntimeError, e:
|
except RuntimeError, e:
|
||||||
sys.exit("ERROR: %s" % e)
|
sys.exit("ERROR: %s" % e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user