From 5eef584c7d49c448ea655f4a6462bcf69830a647 Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 1 Jan 2018 23:45:27 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E8=A7=A3=E5=86=B3=E6=89=93=E5=8D=B0?= =?UTF-8?q?print=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E5=9C=A8=E4=BA=8E=E8=BF=90=E8=A1=8Cdocker=E6=B2=A1?= =?UTF-8?q?=E6=9C=89tty=EF=BC=8C=E4=B9=9F=E5=8F=AF=E4=BB=A5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0PYTHONIOENCODING=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_server.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/run_server.py b/run_server.py index bf8677ab0..1a389e5eb 100644 --- a/run_server.py +++ b/run_server.py @@ -7,7 +7,6 @@ import threading import time import argparse import sys -import io from apps import __version__ @@ -16,6 +15,7 @@ try: except ImportError: CONFIG = type('_', (), {'__getattr__': None})() +os.environ["PYTHONIOENCODING"] = "UTF-8" BASE_DIR = os.path.dirname(os.path.abspath(__file__)) APPS_DIR = os.path.join(BASE_DIR, 'apps') @@ -86,12 +86,12 @@ def start_beat(): os.environ.setdefault('C_FORCE_ROOT', '1') pidfile = '/tmp/beat.pid' if os.path.exists(pidfile): - print("Beat pid file `` exist, remove it".format(pidfile)) + print("Beat pid file `{}` exist, remove it".format(pidfile)) os.unlink(pidfile) time.sleep(0.5) if os.path.exists(pidfile): - print("Beat 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) time.sleep(0.5) @@ -147,7 +147,12 @@ def stop_service(): os.unlink('/tmp/beat.pid') -start_service('all') - - +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Jumpserver start tools") + parser.add_argument("services", type=str, nargs='+', default="all", + choices=("all", "gunicorn", "celery", "beat"), + help="The service to start", + ) + args = parser.parse_args() + start_service(args.services)