瀏覽代碼

1. 项目管理中自定义全局变量=两边可以有空格,建议创建项目时做校验
2. socketio 跨域问题,解决xxx is not an allow origin报错
3. 增加requirement中pymysql包
4. centos7 依赖安装报错解决, 增加豆瓣python源
5. admin.sh中增加requrie命令用于安装依赖python包

席刚 5 年之前
父節點
當前提交
56f463cd97
共有 5 個文件被更改,包括 25 次插入9 次删除
  1. 8 5
      admin.sh
  2. 1 0
      requirements/prod.txt
  3. 14 2
      walle/config/settings_prod.py
  4. 1 1
      walle/service/deployer.py
  5. 1 1
      walle/service/extensions.py

+ 8 - 5
admin.sh

@@ -41,7 +41,7 @@ function init() {
 
 function requirement() {
     source ./venv/bin/activate
-    pip install -r ./requirements/prod.txt
+    pip install -r ./requirements/prod.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
 }
 
 function SystemName() {
@@ -54,7 +54,8 @@ function SystemName() {
                 python get-pip.py
             fi
             echo "安装/更新可能缺少的依赖: mysql-community-devel gcc gcc-c++ python-devel"
-            sudo yum install -y mysql-devel gcc gcc-c++ python-devel MySQL-python
+            # 安装python-devel报错 yum install yum-utils ,yum clean all  yum -y install python-devel
+            sudo yum install -y yum-utils mariadb-devel mysql-devel --skip-broken gcc gcc-c++ python-devel MySQL-python
             ;;
 
         debian|ubuntu|devuan)
@@ -136,7 +137,7 @@ echo "
 function migration() {
     echo "Migration walle"
     echo "----------------"
-   source ./venv/bin/activate
+    source ./venv/bin/activate
     export FLASK_APP=waller.py
     flask db upgrade
     if [ $? == "0" ]; then
@@ -147,6 +148,8 @@ function migration() {
 }
 
 case "$1" in
+    require)
+        requirement;;
     init )
         walle_banner
         init
@@ -177,7 +180,7 @@ case "$1" in
     * )
         walle_banner
         echo "************************************************"
-        echo "Usage: sh admin {init|start|stop|restart|upgrade|migration}"
+        echo "Usage: sh admin {init|require|start|stop|restart|upgrade|migration}"
         echo "************************************************"
         ;;
-esac
+esac

+ 1 - 0
requirements/prod.txt

@@ -41,3 +41,4 @@ pycrypto==2.6.1
 pytz==2015.7
 requests==2.20.0
 GitPython==2.1.11
+pymysql ==0.9.3

+ 14 - 2
walle/config/settings_prod.py

@@ -12,6 +12,15 @@
 import os
 from walle.config.settings import Config
 
+SETTINGS = {
+    "MYSQL_USER": "root",
+    "MYSQL_PASSWORD": "walle",
+    "MYSQL_DATABASE": "walle",
+    "MYSQL_ROOT_PASSWORD": "walle",
+    "MYSQL_HOST": "127.0.0.1",
+    "MYSQL_PORT": 3306,
+}
+
 
 class ProdConfig(Config):
     """Production configuration."""
@@ -22,13 +31,16 @@ class ProdConfig(Config):
     # 服务启动 @TODO
     # HOST 修改为与 nginx server_name 一致.
     # 后续在web hooks与通知中用到此域名.
-    HOST = 'admin.walle-web.io'
+    HOST = '0.0.0.0'
     PORT = 5000
     # https True, http False
     SSL = False
 
     # 数据库设置 @TODO
-    SQLALCHEMY_DATABASE_URI = 'mysql://user:password@localhost:3306/walle?charset=utf8'
+    # SQLALCHEMY_DATABASE_URI = 'mysql://user:password@localhost:3306/walle?charset=utf8'
+    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8mb4'.format(
+        SETTINGS["MYSQL_USER"], SETTINGS["MYSQL_PASSWORD"], SETTINGS["MYSQL_HOST"], SETTINGS["MYSQL_PORT"],
+        SETTINGS["MYSQL_DATABASE"])
     # 阿里云RDS强制释放空闲连接导致经常报错 mysql server has gone way
     # 适当修改该参数即可 单位为秒
     # N秒不用的连接自动释放

+ 1 - 1
walle/service/deployer.py

@@ -104,7 +104,7 @@ class Deployer:
                     var_list = var.split('=', 1)
                     if len(var_list) != 2:
                         continue
-                    self.custom_global_env[var_list[0]] = var_list[1]
+                    self.custom_global_env[var_list[0].strip()] = var_list[1].strip()
 
             self.localhost.init_env(env=self.custom_global_env)
 

+ 1 - 1
walle/service/extensions.py

@@ -19,4 +19,4 @@ login_manager = LoginManager()
 mail = Mail()
 
 permission = Permission()
-socketio = SocketIO(engineio_logger=True, logger=True)
+socketio = SocketIO(engineio_logger=True, logger=True, cors_allowed_origins=[])