From 3300d20c1cdf2e42b7c020cf2dc5ab330901f95f Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 1 Jan 2018 21:04:43 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9beat=20=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=EF=BC=8C=E5=88=A4=E6=96=ADpid=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_server.py | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/run_server.py b/run_server.py index 47f3951e7..45f2b47c4 100644 --- a/run_server.py +++ b/run_server.py @@ -27,7 +27,6 @@ WORKERS = 4 EXIT_EVENT = threading.Event() processes = {} -sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') try: os.makedirs(os.path.join(BASE_DIR, "data", "static")) @@ -85,34 +84,16 @@ def start_beat(): os.chdir(APPS_DIR) os.environ.setdefault('PYTHONOPTIMIZE', '1') os.environ.setdefault('C_FORCE_ROOT', '1') - pidfile = '/tmp/beat.pid ' + pidfile = '/tmp/beat.pid' if os.path.exists(pidfile): - print("Pid file `{}` exist, remove it".format(pidfile)) + print("Beat pid file `` exist, remove it".format(pidfile)) os.unlink(pidfile) - time.sleep(1) + time.sleep(0.5) if os.path.exists(pidfile): - print("Pid file `{}` exist yet, may be something wrong".format(pidfile)) + print("Beat pid file `` exist yet, may be something wrong".format(pidfile)) os.unlink(pidfile) - - scheduler = "django_celery_beat.schedulers:DatabaseScheduler" - options = "--pidfile {} -l {} --scheduler {} --max-interval 60".format( - pidfile, LOG_LEVEL, scheduler, - ) - cmd = 'celery -A common beat {} '.format(options) - p = subprocess.Popen(cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr) - return p - - -def start_service(services): - print(time.ctime()) - print('Jumpserver version {}, more see https://www.jumpserver.org'.format( - __version__)) - print('Quit the server with CONTROL-C.') - - services_all = { - "gunicorn": start_gunicorn, - "celery": start_celery, + time.sleep(0.5) scheduler = "django_celery_beat.schedulers:DatabaseScheduler" options = "--pidfile {} -l {} --scheduler {} --max-interval 60".format( @@ -173,6 +154,7 @@ if __name__ == '__main__': help="The service to start", ) args = parser.parse_args() + try: start_service(args.services) except KeyboardInterrupt: