uwsgi服务器问题-无法运行ssh:无此类文件或目录

时间:2018-11-27 03:18:09

标签: git ssh virtualenv uwsgi

this article中所述,我正在Ubuntu上通过uwsgi和nginix运行flask。根据该文章,我正在使用virtualenv。我已经启动并运行了所有程序,但是遇到git pull问题,我的脚本应该在执行该操作:

Nov 26 19:07:42 airflow-server uwsgi[18636]: Handling change to seer
Nov 26 19:07:42 airflow-server uwsgi[18636]: echo $PATH: b'/home/engineering/github_webhook_endpoint/github_webhook_endpointenv/bin\n'
Nov 26 19:07:42 airflow-server uwsgi[18636]: Fetching origin
Nov 26 19:07:42 airflow-server uwsgi[18636]: error: cannot run ssh: No such file or directory
Nov 26 19:07:42 airflow-server uwsgi[18636]: fatal: unable to fork
Nov 26 19:07:42 airflow-server uwsgi[18636]: error: Could not fetch origin
Nov 26 19:07:42 airflow-server uwsgi[18636]: Successfully git pull'd at /home/engineering/seer

脚本:

from flask import Flask, request
from pathlib import Path
import os
import json
import requests
import subprocess

local_dir = '/home/engineering'

application = Flask(__name__)

def handle_request(data):
    repo_name = data['repository']['name']
    local_repos = [x.name for x in Path(local_dir).iterdir()]

    print(f'Handling change to {repo_name}')

    if repo_name in local_repos:
        print('echo $PATH:', subprocess.check_output("echo $PATH",shell=True))
        os.system(f'cd {local_dir}/{repo_name} && /usr/bin/git fetch --all && /usr/bin/git reset --hard origin/master')
        print(f'Successfully git pull\'d at {local_dir}/{repo_name}')
    else:
        print(f'No such repo at {local_dir}/{repo_name}')

@application.route('/',methods=['POST'])
def foo():
    data = json.loads(request.data)
    handle_request(data)
    return 'OK'

if __name__ == '__main__':
    application.run(host='0.0.0.0')

我一直在在线查看解决方案,但是似乎都不是针对我的特定问题而写的,但是我却一无所获。我有git在正常环境中使用的SSH密钥,但是我不确定如何在此virtualenv中“告诉” git以使用它们。

0 个答案:

没有答案