From f08b2202abb33b2c2d5c177e1dac59092954de42 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 21 Jun 2019 22:33:53 +0800 Subject: [PATCH 1/6] updated Jenkinsfile --- .dockerignore | 3 +- Jenkinsfile | 30 +++++++++----------- crawlab/app.py | 4 +-- docker-compose.yml | 2 +- frontend/src/views/schedule/ScheduleList.vue | 9 +++++- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.dockerignore b/.dockerignore index 30de240bb..5900766d7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ .idea logs -*.log \ No newline at end of file +*.log +node_modules/ \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 2e3c7ee60..e4bb2e1c3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,17 +6,12 @@ pipeline { } environment { - HOME = '/home/yeqing' - NODE_HOME = '/home/yeqing/.nvm/versions/node/v8.12.0' - ROOT_DIR = "/home/yeqing/jenkins_home/workspace/crawlab_${GIT_BRANCH}" - PYTHON_HOME = '/home/yeqing/.pyenv/shims' } stages { stage('Setup') { steps { echo "Running Setup..." - // sh '. /home/yeqing/.profile' script { if (env.GIT_BRANCH == 'develop') { env.MODE = 'test' @@ -28,18 +23,12 @@ pipeline { } } } - stage('Build Frontend') { + stage('Build') { steps { - echo "Building frontend..." - // sh "${NODE_HOME}/bin/node ${NODE_HOME}/bin/npm install -g yarn pm2 --registry=http://registry.npm.taobao.org/" - sh "cd ${ROOT_DIR}/frontend && ${NODE_HOME}/bin/node ${NODE_HOME}/bin/yarn install --registry=http://registry.npm.taobao.org/ --scripts-prepend-node-path=${NODE_HOME}/bin/node" - sh "cd ${ROOT_DIR}/frontend && ${NODE_HOME}/bin/node ${ROOT_DIR}/frontend/node_modules/.bin/vue-cli-service build --mode=${MODE}" - } - } - stage('Build Backend') { - steps { - echo "Building backend..." - sh "${PYTHON_HOME}/pip install -r ${ROOT_DIR}/crawlab/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple" + echo "Building..." + sh """ + docker build -t crawlab:latest . + """ } } stage('Test') { @@ -50,7 +39,14 @@ pipeline { stage('Deploy') { steps { echo 'Deploying....' - sh "${NODE_HOME}/bin/node ${NODE_HOME}/bin/pm2 reload all" + sh """ + docker stop crawlab | true + docker run -d --rm --restart always --name crawlab \ + -p 8080:8080 \ + -p 8000:8000 \ + -v /home/yeqing/.env.production:/opt/crawlab/frontend/.env.production \ + -v /home/yeqing/config.py:/opt/crawlab/crawlab/config/config.py + """ } } } diff --git a/crawlab/app.py b/crawlab/app.py index db6fa95e2..493c9bedd 100644 --- a/crawlab/app.py +++ b/crawlab/app.py @@ -6,7 +6,6 @@ from flask_cors import CORS from flask_restful import Api # from flask_restplus import Api -from gevent import monkey, pywsgi file_dir = os.path.dirname(os.path.realpath(__file__)) root_path = os.path.abspath(os.path.join(file_dir, '.')) @@ -104,5 +103,4 @@ def update_nodes_status_online(event): if __name__ == '__main__': # run app instance - server = pywsgi.WSGIServer((FLASK_HOST, FLASK_PORT), app) - server.serve_forever() + app.run(host=FLASK_HOST, port=FLASK_PORT, threaded=True) diff --git a/docker-compose.yml b/docker-compose.yml index 8e4c5eaa8..682f404b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: master: image: tikazyq/crawlab:latest container_name: crawlab - volumns: + volumes: - /home/yeqing/config.py:/opt/crawlab/crawlab/config/config.py # 后端配置文件 - /home/yeqing/.env.production:/opt/crawlab/frontend/.env.production # 前端配置文件 ports: diff --git a/frontend/src/views/schedule/ScheduleList.vue b/frontend/src/views/schedule/ScheduleList.vue index 870a70b0a..8887e9473 100644 --- a/frontend/src/views/schedule/ScheduleList.vue +++ b/frontend/src/views/schedule/ScheduleList.vue @@ -16,7 +16,14 @@ - + + From f6888aea3b53132fa7c86e31da67b83603bccce5 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 21 Jun 2019 22:34:48 +0800 Subject: [PATCH 2/6] updated Jenkinsfile --- Jenkinsfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e4bb2e1c3..182c419c6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,9 +5,6 @@ pipeline { } } - environment { - } - stages { stage('Setup') { steps { From 5c6e0bd95e4921b8535fe829d9dc54ad8785f903 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 21 Jun 2019 22:37:02 +0800 Subject: [PATCH 3/6] updated Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 182c419c6..268ce9824 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,6 +24,7 @@ pipeline { steps { echo "Building..." sh """ + echo `whoami` docker build -t crawlab:latest . """ } From 10f27efae64173b45aaf7d4de5b6998c8687c5fd Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 21 Jun 2019 22:43:50 +0800 Subject: [PATCH 4/6] updated Jenkinsfile --- Jenkinsfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 268ce9824..0844bdf3b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,13 +18,16 @@ pipeline { env.MODE = 'test' } } + sh """ + echo `whoami` + newgrp docker + """ } } stage('Build') { steps { echo "Building..." sh """ - echo `whoami` docker build -t crawlab:latest . """ } From aa4e76867d9a81b73da1d06cc1c75812a3ae639e Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 21 Jun 2019 22:46:12 +0800 Subject: [PATCH 5/6] updated Jenkinsfile --- Jenkinsfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0844bdf3b..182c419c6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,10 +18,6 @@ pipeline { env.MODE = 'test' } } - sh """ - echo `whoami` - newgrp docker - """ } } stage('Build') { From 006c755e4d418c73347c19c7782a6cec99c22fc2 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Sat, 22 Jun 2019 09:57:53 +0800 Subject: [PATCH 6/6] updated requirements.txt --- crawlab/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crawlab/requirements.txt b/crawlab/requirements.txt index 39912ed90..fed8fb801 100644 --- a/crawlab/requirements.txt +++ b/crawlab/requirements.txt @@ -11,3 +11,5 @@ lxml==4.3.3 Flask_Cors==3.0.7 Werkzeug==0.15.2 eventlet +Celery +Flower