From 29328d293b2efbdf1377ef4848c21329846610ce Mon Sep 17 00:00:00 2001 From: fxC Date: Sun, 21 Nov 2021 22:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmac=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E4=B8=8B=E5=90=AF=E5=8A=A8=E6=9C=8D=E5=8A=A1=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/management/commands/services/command.py | 4 ++-- fir_ser/api/management/commands/services/services/beat.py | 7 +++++-- .../management/commands/services/services/celery_base.py | 6 ++++-- .../api/management/commands/services/services/flower.py | 6 ++++-- fir_ser/api/management/commands/services/services/uwsgi.py | 7 ++++--- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/fir_ser/api/management/commands/services/command.py b/fir_ser/api/management/commands/services/command.py index 70e90e0..399c01d 100644 --- a/fir_ser/api/management/commands/services/command.py +++ b/fir_ser/api/management/commands/services/command.py @@ -105,8 +105,8 @@ class BaseActionCommand(BaseCommand): parser.add_argument('-usm', '--uwsgi_socket_mode', nargs="?", const=True, help='run to bind socket mode, default http mode, only uwsgi service') parser.add_argument('-f', '--force', nargs="?", const=True) - parser.add_argument('-u', '--uid', nargs="?", default='root', type=str) - parser.add_argument('-g', '--gid', nargs="?", default='root', type=str) + parser.add_argument('-u', '--uid', nargs="?", default='', type=str) + parser.add_argument('-g', '--gid', nargs="?", default='', type=str) def initial_util(self, *args, **options): service_names = options.get('services') diff --git a/fir_ser/api/management/commands/services/services/beat.py b/fir_ser/api/management/commands/services/services/beat.py index 3f7c736..4f4bc29 100644 --- a/fir_ser/api/management/commands/services/services/beat.py +++ b/fir_ser/api/management/commands/services/services/beat.py @@ -20,11 +20,14 @@ class BeatService(BaseService): 'celery', '-A', 'fir_ser', 'beat', '-l', 'INFO', - '--uid', self.uid, - '--gid', self.gid, '--scheduler', scheduler, '--max-interval', '60' ] + if self.uid: + cmd.extend(['--uid', self.uid]) + if self.gid: + cmd.extend(['--gid', self.gid]) + return cmd @property diff --git a/fir_ser/api/management/commands/services/services/celery_base.py b/fir_ser/api/management/commands/services/services/celery_base.py index 1c06801..48731bf 100644 --- a/fir_ser/api/management/commands/services/services/celery_base.py +++ b/fir_ser/api/management/commands/services/services/celery_base.py @@ -26,12 +26,14 @@ class CeleryBaseService(BaseService): 'celery', '-A', 'fir_ser', 'worker', '-l', 'INFO', - '--uid', self.uid, - '--gid', self.gid, '-c', str(self.num), '-Q', self.queue, '-n', f'{self.queue}@{server_hostname}' ] + if self.uid: + cmd.extend(['--uid', self.uid]) + if self.gid: + cmd.extend(['--gid', self.gid]) return cmd @property diff --git a/fir_ser/api/management/commands/services/services/flower.py b/fir_ser/api/management/commands/services/services/flower.py index 7e72027..e3f0ad4 100644 --- a/fir_ser/api/management/commands/services/services/flower.py +++ b/fir_ser/api/management/commands/services/services/flower.py @@ -19,8 +19,6 @@ class FlowerService(BaseService): 'celery', '-A', 'fir_ser', 'flower', '-l', 'INFO', - '--uid', self.uid, - '--gid', self.gid, '--url_prefix=/flower', '--auto_refresh=False', '--max_tasks=1000', @@ -29,6 +27,10 @@ class FlowerService(BaseService): # '--basic_auth=flower:ninevenxxx' # '--tasks_columns=uuid,name,args,state,received,started,runtime,worker' ] + if self.uid: + cmd.extend(['--uid', self.uid]) + if self.gid: + cmd.extend(['--gid', self.gid]) return cmd @property diff --git a/fir_ser/api/management/commands/services/services/uwsgi.py b/fir_ser/api/management/commands/services/services/uwsgi.py index 443035b..c79291a 100644 --- a/fir_ser/api/management/commands/services/services/uwsgi.py +++ b/fir_ser/api/management/commands/services/services/uwsgi.py @@ -20,8 +20,6 @@ class UwsgiService(BaseService): bind = f'{SOCKET_HOST}:{SOCKET_PORT}' cmd = [ 'uwsgi', - '--uid', self.uid, - '--gid', self.gid, '--processes', f'{self.processes}', '--threads', f'{self.threads}', '--wsgi-file', f"{BASE_DIR}/fir_ser/wsgi.py", @@ -32,7 +30,10 @@ class UwsgiService(BaseService): '--enable-threads', '--master', ] - + if self.uid: + cmd.extend(['--uid', self.uid]) + if self.gid: + cmd.extend(['--gid', self.gid]) if self.uwsgi_socket_mode: cmd.extend(['--socket', bind]) else: