优化uwsgi 启动服务

publicsignpoll
youngS 3 years ago
parent 1a9cae8cb7
commit 7c5ab20dd9
  1. 4
      fir_ser/api/management/commands/services/command.py
  2. 9
      fir_ser/api/management/commands/services/hands.py
  3. 1
      fir_ser/api/management/commands/services/utils.py

@ -99,8 +99,8 @@ class BaseActionCommand(BaseCommand):
'services', nargs='+', choices=Services.export_services_values(), help='Service',
)
parser.add_argument('-d', '--daemon', nargs="?", const=True)
parser.add_argument('-up', '--uwsgi_processes', type=int, nargs="?", default=4)
parser.add_argument('-ut', '--uwsgi_threads', type=int, nargs="?", default=2)
parser.add_argument('-up', '--uwsgi_processes', type=int, nargs="?", default=get_sys_process_num())
parser.add_argument('-ut', '--uwsgi_threads', type=int, nargs="?", default=get_sys_thread_num())
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)

@ -3,6 +3,7 @@ import sys
import logging
from django.conf import settings
from config import BASE_DIR
import psutil
import time
import subprocess
@ -65,3 +66,11 @@ def prepare():
check_database_connection()
check_migrations()
perform_db_migrate()
def get_sys_thread_num():
return psutil.cpu_count(False) if psutil.cpu_count(False) else 2
def get_sys_process_num():
return psutil.cpu_count(True) if psutil.cpu_count(True) else 4

@ -1,6 +1,5 @@
import threading
import signal
import time
import daemon
from daemon import pidfile
from .hands import *

Loading…
Cancel
Save