Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_exit_handler(self, mock_logging):
daemon.NoDaemon.exit_flag = False
self.daemon.handle_program_exit(33, None)
self.assertEquals(daemon.NoDaemon.exit_flag, True)
self.assertTrue(self.daemonizable.stop.called)
def setUp(self, mock_signal):
self.daemonizable = Mock()
self.daemon = daemon.NoDaemon(daemonizable=self.daemonizable)
def test_create(self):
self.assertIsInstance(self.daemon, daemon.NoDaemon)
def handle_program_exit(signum, frame):
LOG.info('Got signal {0}. Exiting ...'.format(signum))
NoDaemon.exit_flag = True
NoDaemon.instance.daemonizable.stop()
print("--no-api mode is not available on windows")
return 69 # os.EX_UNAVAILABLE
freezer_utils.create_dir(CONF.jobs_dir, do_log=False)
freezer_scheduler = FreezerScheduler(apiclient=apiclient,
interval=int(CONF.interval),
job_path=CONF.jobs_dir,
concurrent_jobs=CONF.concurrent_jobs)
if CONF.no_daemon:
print('Freezer Scheduler running in no-daemon mode')
LOG.debug('Freezer Scheduler running in no-daemon mode')
if winutils.is_windows():
daemon = win_daemon.NoDaemon(daemonizable=freezer_scheduler)
else:
daemon = linux_daemon.NoDaemon(daemonizable=freezer_scheduler)
else:
if winutils.is_windows():
daemon = win_daemon.Daemon(daemonizable=freezer_scheduler,
interval=int(CONF.interval),
job_path=CONF.jobs_dir,
insecure=CONF.insecure,
concurrent_jobs=CONF.concurrent_jobs)
else:
daemon = linux_daemon.Daemon(daemonizable=freezer_scheduler)
if CONF.action == 'start':
daemon.start()
elif CONF.action == 'stop':
daemon.stop()
elif CONF.action == 'restart':
daemon.restart()
def signal_map(self):
return {
signal.SIGTERM: NoDaemon.handle_program_exit,
signal.SIGINT: NoDaemon.handle_program_exit,
signal.SIGHUP: NoDaemon.handle_reload,
}
def handle_reload(signum, frame):
NoDaemon.instance.daemonizable.reload()