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: