Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if cmd == 'status' or opts.show_status:
return self.show_status(opts)
if opts.monitor_restart and opts.reload:
self.out('Cannot user --monitor-restart with --reload')
return 2
if opts.monitor_restart and not os.environ.get(self._monitor_environ_key):
# gearbox serve was started with an angel and we are not already inside the angel.
# Switch this process to being the angel and start a new one with the real server.
return self.restart_with_monitor()
if opts.reload and not hupper.is_active():
if self.verbose > 1:
self.out('Running reloading file monitor')
reloader = hupper.reloader.Reloader(
worker_path='gearbox.main.main',
reload_interval=opts.reload_interval,
monitor_factory=hupper.reloader.find_default_monitor_factory(
logging.getLogger('gearbox')
),
logger=logging.getLogger('gearbox'),
)
reloader.run()
if hupper.is_active():
# Tack also config file changes
hupper.get_reloader().watch_files([opts.config_file])
if cmd == 'restart' or cmd == 'stop':
result = self.stop_daemon(opts)
if result:
if opts.monitor_restart and opts.reload:
self.out('Cannot user --monitor-restart with --reload')
return 2
if opts.monitor_restart and not os.environ.get(self._monitor_environ_key):
# gearbox serve was started with an angel and we are not already inside the angel.
# Switch this process to being the angel and start a new one with the real server.
return self.restart_with_monitor()
if opts.reload and not hupper.is_active():
if self.verbose > 1:
self.out('Running reloading file monitor')
reloader = hupper.reloader.Reloader(
worker_path='gearbox.main.main',
reload_interval=opts.reload_interval,
monitor_factory=hupper.reloader.find_default_monitor_factory(
logging.getLogger('gearbox')
),
logger=logging.getLogger('gearbox'),
)
reloader.run()
if hupper.is_active():
# Tack also config file changes
hupper.get_reloader().watch_files([opts.config_file])
if cmd == 'restart' or cmd == 'stop':
result = self.stop_daemon(opts)
if result:
if cmd == 'restart':
self.out("Could not stop daemon; aborting")
else: