def main(): try: opts = parse_args(sys.argv[1:]) init_logger(opts.verbose) LOGGER.info('Starting Service...') node_count = int(opts.node_count) node_template = opts.node_template boot_node = opts.boot_node docker_starter = DockerStarter(node_count, node_template, boot_node) services = docker_starter.generate_nodes() docker_starter.start_services() benchmark = opts.benchmark monitor = DockerMonitor(services, benchmark) monitor.start() publisher_url = opts.publisher_url server_node_url = opts.server_node_url load = opts.load client = SawtoothClient(publisher_url, server_node_url, load, benchmark) client.subscribe() client.generate_load() client.start_load() except (KeyboardInterrupt, SubscriberError): sys.exit(0)
def main(): try: opts = parse_args(sys.argv[1:]) init_logger(opts.verbose) load = int(opts.load) or 10 benchmark = opts.benchmark publisher = opts.publisher subscriber = SawtoothSubscriber(publisher, benchmark, load) subscriber.subscribe_to_event() subscriber.run() except KeyboardInterrupt: sys.exit(0)
def main(): try: opts = parse_args(sys.argv[1:]) init_logger(opts.verbose) LOGGER.info('Starting The Docker Starter...') node_count = int(opts.node_count) node_template = opts.node_template boot_node = opts.boot_node docker_starter_instance = DockerStarter(node_count, node_template, boot_node) docker_starter_instance.generate_nodes() docker_starter_instance.start_services() except KeyboardInterrupt: LOGGER.info('Stopping The Docker Starter...') sys.exit(0) pass
def init_queue_and_pidfile(): global MAIL_INCHECK_QUEUE, incheck_pid_file if len(sys.argv) > 1: MAIL_INCHECK_QUEUE = sys.argv[1] incheck_pid_file = MAIL_INCHECK_QUEUE + '.pid' if __name__ == "__main__": globals()['_DEBUG'] = common.check_debug() init_queue_and_pidfile() common.init_cfg_default() common.init_run_user(common.cfgDefault.get('global', 'user')) common.init_makedir() common.init_pid_file(incheck_pid_file) common.init_logger(MAIL_INCHECK_QUEUE, len(sys.argv) > 2, _DEBUG) clamav_sock = common.cfgDefault.get('clamav', 'sock') review_help_mode = common.cfgDefault.get('review_help', 'mode') init_resource() gevent.spawn(init_resource_routine) # 运行程序 EXIT_CODE = 0 outinfo(u"program start") try: # 设置监听信号量 common.gevent_signal_init(signal_handle) scanner() except KeyboardInterrupt: signal_handle('sigint') except:
def init_resource(): global setting settings = Settings.objects.all() if settings: setting = settings[0] if __name__ == "__main__": globals()['_DEBUG'] = Common.check_debug(2) Common.init_cfg_default() Common.init_run_user(Common.cfgDefault.get('global', 'user')) Common.init_pid_file('Statistics.pid') Common.init_logger('Statistics', len(sys.argv) > 1, _DEBUG) # 获取参数 if len(sys.argv) >= 2: p_date = sys.argv[1] elif len(sys.argv) == 1: p_date = str(datetime.date.today()) else: outerror("param_error") sys.exit(1) # 运行程序 EXIT_CODE = 0 outinfo("program start") init_resource()
sig = res.get('result', '') if not sig: outinfo('restart server') outinfo('restart postgres') subprocess.call('/etc/init.d/postgresql_dspam restart', shell=True) outinfo('restart dsapm') subprocess.call('/etc/init.d/dspam restart', shell=True) outinfo('restart server end') gevent.sleep(600) def main(): gevent.joinall([ gevent.spawn(check_dspam), ]) if __name__ == "__main__": globals()['_DEBUG'] = Common.check_debug() # Common.init_cfg_default() # Common.init_run_user(Common.cfgDefault.get('global', 'user')) # Common.init_pid_file('CheckDspam.pid') Common.init_logger('CheckDspam', len(sys.argv) > 1, _DEBUG) # 运行程序 EXIT_CODE = 0 outinfo("program start") main() outinfo("program quit") sys.exit(EXIT_CODE)
# ########################################################### def main(): init_resource() gevent.joinall([ gevent.spawn(init_resource_routine), gevent.spawn(service_notice, 'relay'), gevent.spawn(service_notice, 'collect'), gevent.spawn(bulk_notice), gevent.spawn(review_notice), gevent.spawn(ip_notice), gevent.spawn(jam_notice), gevent.spawn(collect_limit_notice), gevent.spawn(relay_limit_notice), gevent.spawn(collect_dielver_exception_notice), ]) if __name__ == "__main__": globals()['_DEBUG'] = Common.check_debug() Common.init_cfg_default() Common.init_run_user(Common.cfgDefault.get('global', 'user')) Common.init_pid_file('Notice.pid') Common.init_logger('Notice', len(sys.argv) > 1, _DEBUG) # 运行程序 EXIT_CODE = 0 outinfo("program start") main() outinfo("program quit") sys.exit(EXIT_CODE)
pass while redis.rpoplpush(CREDIS_KEY_temp, CREDIS_KEY) is not None: pass def main(): init() gevent.joinall([ gevent.spawn(sender_credit), gevent.spawn(csender_credit), gevent.spawn(init_resource_routine), gevent.spawn(clear_redis_routine), #gevent.spawn(push_data), ]) if __name__ == "__main__": globals()['_DEBUG'] = common.check_debug() common.init_cfg_default() common.init_run_user(common.cfgDefault.get('global', 'user')) common.init_pid_file('SenderCredit.pid') common.init_logger('SenderCredit', len(sys.argv) > 1, _DEBUG) # 运行程序 EXIT_CODE = 0 outinfo("program start") main() outinfo("program quit") sys.exit(EXIT_CODE)
def loginfo(logid, msg): msg = u'[%s] %s' % (logid, msg) outinfo(msg) def logerror(logid, msg): msg = u'[%s] %s' % (logid, msg) outerror(msg) if __name__ == "__main__": globals()['_DEBUG'] = Common.check_debug() Common.init_cfg_default() Common.init_run_user(Common.cfgDefault.get('global', 'user')) Common.init_pid_file('rulefilter.pid') Common.init_logger('RuleFilter', len(sys.argv) > 1, _DEBUG) # 运行服务 EXIT_CODE = 0 outinfo("program start") try: # 设置监听信号量 gevent.signal(signal.SIGTERM, signal_handle, 'sigterm') gevent.signal(signal.SIGALRM, signal_handle, 'sigalrm') # 启动流服务器 server = StreamServer(('127.0.0.1', 10026), main) server.serve_forever() except KeyboardInterrupt: signal_handle('sigint')
# for task_id in _threads: # outinfo('task back to queue: %s' % task_id) # redis.rpush(MAIL_INCHECK_QUEUE, task_id) # if mode != 'sigint': sys.exit(0) ############################################################ if __name__ == "__main__": globals()['_DEBUG'] = common.check_debug() common.init_cfg_default() common.init_run_user(common.cfgDefault.get('global', 'user')) common.make_dir([mails_path, rcpts_path, error_path, froms_path]) common.init_makedir() common.init_pid_file('CHandleMail.pid') common.init_logger('CHandleMail', len(sys.argv) > 1, _DEBUG) # 运行程序 EXIT_CODE = 0 outinfo("program start") try: # 设置监听信号量 common.gevent_signal_init(signal_handle) scanner() except KeyboardInterrupt: signal_handle('sigint') except: outerror(traceback.format_exc()) EXIT_CODE = 1 outinfo("program quit")
redis.rename(KEY_1_TEMP, KEY_1) def init_resource(): global check_setting check_settings = CheckSettings.objects.all() if check_settings: check_setting = check_settings[0] if __name__ == "__main__": globals()['_DEBUG'] = Common.check_debug(2) Common.init_cfg_default() Common.init_run_user(Common.cfgDefault.get('global', 'user')) Common.init_pid_file('StatSenderGreyList.pid') Common.init_logger('StatSenderGreyList', len(sys.argv) > 1, _DEBUG) # 运行程序 EXIT_CODE = 0 outinfo("program start") init_resource() try: stat_sender_grey_list() stat_sender_grey_list_1() except: outerror(traceback.format_exc()) EXIT_CODE = 1 outinfo("program quit") sys.exit(EXIT_CODE)
def init_resource(): global setting settings = Settings.objects.all() if settings: setting = settings[0] if __name__ == "__main__": globals()['_DEBUG'] = Common.check_debug(2) Common.init_cfg_default() Common.init_run_user(Common.cfgDefault.get('daily_cron', 'user')) Common.init_pid_file('Daily_cron.pid') Common.init_logger('Daily_cron', len(sys.argv) > 1, _DEBUG) # 运行程序 EXIT_CODE = 0 outinfo("program start") init_resource() try: clear_email_back() monitor_customer() customer_summary() set_bulk_customer() save_postfix_status() check_statistic() save_keyword_review_status() review_statistic()
def init(): while redis.rpoplpush('relay_sync_temp', 'relay_sync') is not None: pass while redis.rpoplpush('collect_sync_temp', 'collect_sync') is not None: pass def main(): init() gevent.joinall([ gevent.spawn(make_dir), gevent.spawn(sync_mail, 'relay', get_mail_model), gevent.spawn(sync_mail, 'collect', get_collect_mail_model), ]) if __name__ == "__main__": globals()['_DEBUG'] = Common.check_debug() # Common.init_cfg_default() # Common.init_run_user(Common.cfgDefault.get('global', 'user')) Common.init_pid_file('SyncMail.pid') Common.init_logger('SyncMail', len(sys.argv) > 1, _DEBUG) # 运行程序 EXIT_CODE = 0 outinfo("program start") main() outinfo("program quit") sys.exit(EXIT_CODE)