from citizendesk.common.utils import get_client_ip from citizendesk.common.utils import get_logger logger = get_logger() logger.info('page not found: ' + str(request.method) + ' on ' + str(request.url) + ', by ' + str(get_client_ip())) return 'page not found', 404 def run_flask(dbname, server, mongo, config_path, debug=False): from citizendesk.common.utils import get_logger logger = get_logger() state = prepare_reporting(mongo, dbname, config_path) if not state: logger.warning('quiting the feeds daemon for not successful startup') return app.run(host=server[0], port=server[1], debug=debug, threaded=True) if __name__ == '__main__': file_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.dirname(os.path.dirname(file_dir))) from citizendesk.common.utils import setup_logger default_server = (DEFAULT_HOST, DEFAULT_PORT) default_mongo = (MONGODB_SERVER_HOST, MONGODB_SERVER_PORT) setup_logger() run_flask(DB_NAME, server=default_server, mongo=default_mongo, config_path=CONFIG_PATH, debug=True)
if __name__ == '__main__': file_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.dirname(os.path.dirname(file_dir))) try: from citizendesk.common.utils import setup_logger, get_logger, set_allowed_ips from citizendesk.common.utils import set_pid_path, set_daemon_name from citizendesk.common.utils import daemonize, set_user, cleanup, exit_handler from citizendesk.outgest.run import run_flask except: sys.stderr.write('citizen modules not installed\n') os._exit(1) params.use_specs() setup_logger(params.get_log_path()) set_pid_path(params.get_pid_path()) set_allowed_ips(params.get_allowed_ips()) set_daemon_name(DAEMON_NAME) atexit.register(cleanup) signal.signal(signal.SIGTERM, exit_handler) signal.signal(signal.SIGINT, exit_handler) if params.to_daemonize(): daemonize(params.get_home_dir(), params.get_pid_path()) set_user(params.get_user_id(), params.get_group_id(), params.get_pid_path()) logger = get_logger() try:
if __name__ == '__main__': file_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(os.path.dirname(os.path.dirname(file_dir))) try: from citizendesk.common.utils import setup_logger, get_logger, set_allowed_ips from citizendesk.common.utils import set_pid_path, set_daemon_name from citizendesk.common.utils import daemonize, set_user, cleanup, exit_handler from citizendesk.ingest.url.run import run_flask except: sys.stderr.write('citizen modules not installed\n') os._exit(1) params.use_specs() setup_logger(params.get_log_path()) set_pid_path(params.get_pid_path()) set_allowed_ips(params.get_allowed_ips()) set_daemon_name(DAEMON_NAME) atexit.register(cleanup) signal.signal(signal.SIGTERM, exit_handler) signal.signal(signal.SIGINT, exit_handler) if params.to_daemonize(): daemonize(params.get_home_dir(), params.get_pid_path()) set_user(params.get_user_id(), params.get_group_id(), params.get_pid_path()) logger = get_logger() try: logger.info('starting the ' + str(DAEMON_NAME))