Unexpected behavior from Popen once web app is deployed with apache

◇◆丶佛笑我妖孽 提交于 2019-12-12 03:03:36

问题


I have some code that uses subprocess to look at the logs from a git directory. My code seems to work fine when executed in a local django dev environment. Once deployed however (with Apache / mode_wsgi) the output from stdout read() comes back empty. My development and production machine are the same right now, and I also tried making sure every file was readable.

Does anybody have an idea why Popen is not returning any output once deployed here? Thanks.

def getGitLogs(projectName, searchTerm=None, since):
    os.chdir(os.path.join(settings.SCM_GIT, projectName))
    cmd = "git log --since {0} -p".format(since)
    p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
    output = p.stdout.read()
    ### here output comes back as expected in dev environment, but empty in once deployed
    return filterCommits(parseCommits(output), searchTerm)

回答1:


  1. Chain your chdir as part of your command (ie, cd /foo/bar/zoo)
  2. Pass the full path to git

So your command would end up cd /foo/bar/zoo && /usr/bin/git log --since



来源:https://stackoverflow.com/questions/10644037/unexpected-behavior-from-popen-once-web-app-is-deployed-with-apache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!