Skip to content

Commit

Permalink
Merge pull request #73 from tikazyq/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Marvin Zhang authored Jun 22, 2019
2 parents 3d34578 + 006c755 commit c913f9d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
logs
*.log
*.log
node_modules/
33 changes: 13 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@ 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'
Expand All @@ -28,18 +20,12 @@ pipeline {
}
}
}
stage('Build Frontend') {
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') {
stage('Build') {
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') {
Expand All @@ -50,7 +36,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
"""
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions crawlab/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '.'))
Expand Down Expand Up @@ -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)
2 changes: 2 additions & 0 deletions crawlab/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ lxml==4.3.3
Flask_Cors==3.0.7
Werkzeug==0.15.2
eventlet
Celery
Flower
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/views/schedule/ScheduleList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
</el-form-item>
<el-form-item :label="$t('Spider')" prop="spider_id" required>
<el-select v-model="scheduleForm.spider_id" filterable>
<el-option v-for="op in spiderList" :key="op._id" :value="op._id" :label="op.name"></el-option>
<el-option
v-for="op in spiderList"
:key="op._id"
:value="op._id"
:label="op.name"
:disabled="!op.cmd || !op.deploy_ts"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('Cron')" prop="cron" :rules="cronRules" required>
Expand Down

0 comments on commit c913f9d

Please sign in to comment.