亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

github - Automate deployment issues using Python
大家講道理
大家講道理 2017-05-24 11:35:21
0
1
1183

My job is front-end, and recently I want to use GitHub's webhook Flask to do a simple automated deployment. The requirements are very simple:
Automatically pull the code through the webhook interface when there is a submission, and restart uwsgi.

New to python, code lightly.

flask code (the directory structure refers to the directory in "FLASK WEB Development", which will not be posted); the main code is as follows:

# coding=utf-8
import os
from flask import request, json, jsonify
from threading import Thread
from . import main


def restart():
    os.system('./reload.sh')


@main.route('/')
def welcome():
    user_agent = request.headers.get('User-Agent')
    return "Welcome, %s" % user_agent


@main.route('/webhook', methods=['POST'])
def webhook():
    print('---------------------begin----------------------')
    print(request.get_json())

    print('---------------------end----------------------')
    push_info = request.get_json()
    commit_info = push_info['commits']
    if push_info['ref'] == 'refs/heads/master':
        print('master分支有提交')
        print(push_info['commits'])
        os.system('git pull origin master')

    if push_info['commits'][0]['committer']['email'] == '**********@qq.com':
        print('確認(rèn)是自己提交的')

    data = {
        'hello': 'world',
    }
    js = json.dumps(data)
    resp = jsonify(data)
    resp.status_code = 200
    t = Thread(target=restart,  daemon=True)
    t.start()
    return resp

reload.sh script code

#/usr/bin/sh
sleep 10s
killall -s INT /www/webhook/bin/uwsgi
sleep 10s
uwsgi uwsgi.ini

The problems encountered are as follows:

1.return語(yǔ)句不會(huì)執(zhí)行,因?yàn)榫€程中把uwsgi殺死了
2.腳本關(guān)閉uwsgi報(bào)  `is taking too much time to die...NO MERCY !!!`
3.上一步時(shí)間太長(zhǎng)導(dǎo)致uwsgi重啟失敗

Is there anyone out there who can help me figure out what’s wrong and how to fix it

大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

reply all(1)
習(xí)慣沉默

Restart the server using:

ps -ef | grep uwsgi | grep -v -E 'grep' | xargs kill -USR1
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template