liqian 3 лет назад
Родитель
Сommit
2ff2aa02d4
5 измененных файлов с 24 добавлено и 13 удалено
  1. 2 0
      .gitignore
  2. 5 4
      app.py
  3. 11 4
      config.py
  4. 1 1
      env.conf
  5. 5 4
      requirements.txt

+ 2 - 0
.gitignore

@@ -60,3 +60,5 @@ target/
 
 .idea/
 
+env.conf
+

+ 5 - 4
app.py

@@ -1,6 +1,3 @@
-from gevent import monkey
-monkey.patch_all()
-
 import json
 import time
 
@@ -16,7 +13,11 @@ import ast
 from gevent.pywsgi import WSGIServer
 from multiprocessing import cpu_count, Process
 from utils import update_video_w_h_rate
-#from werkzeug.middleware.profiler import ProfilerMiddleware
+# from werkzeug.middleware.profiler import ProfilerMiddleware
+from gevent import monkey
+
+monkey.patch_all()
+
 app = Flask(__name__)
 #app.wsgi_app = ProfilerMiddleware(app.wsgi_app)
 log_ = Log()

+ 11 - 4
config.py

@@ -256,7 +256,14 @@ class ProductionConfig(BaseConfig):
 
 
 def set_config():
-    return DevelopmentConfig()
-    # return TestConfig()
-    # return PreProductionConfig()
-    # return ProductionConfig()
+    with open('env.conf', 'r') as env_f:
+        line = env_f.read()
+        env = line.split('=')[1].strip()
+    if env == 'dev':
+        return DevelopmentConfig()
+    elif env == 'test':
+        return TestConfig()
+    elif env == 'pre':
+        return PreProductionConfig()
+    elif env == 'pro':
+        return ProductionConfig()

+ 1 - 1
env.conf

@@ -1 +1 @@
-ENV=dev
+ENV=dev

+ 5 - 4
requirements.txt

@@ -1,8 +1,9 @@
+numpy==1.19.2
+requests==2.24.0
 PyMySQL==1.0.2
+apache_skywalking==0.7.0
+Flask==1.1.2
 gevent==20.9.0
 redis==3.5.3
-requests==2.24.0
 psycopg2_binary==2.9.1
-numpy==1.19.2
-Flask==1.1.2
-psycopg2==2.9.2
+psycopg2==2.9.3