TLDR: I can run git pull
from the terminal and it works, but when I run os.system("/usr/bin/git pull")
it doesn’t work
I have a uWSGI server working and I’m trying to get a GitHub Webhook to trigger a git pull
command to update the code on the server automatically.
I used to use PythonAnywhere, but I’m migrating over to my own Ubuntu server. I’ve had the auto-update working perfectly on PythonAnywhere, but I just can’t get it to work on my own server.
I had and solved several problems to get to where I am (including incorrect working directories, sudo permissions etc.) but this current problem has me stumped.
In python, I run exit_code = os.system("/usr/bin/git pull")
.
I also have a local post-merge hook that runs sudo systemctl restart myapp.service
.
When the auto-update is triggered, I get the following in my uWSGI log:
Git about to pull
error: cannot run ssh: No such file or directory
fatal: unable to fork
Exit code: 256
Some research I did suggested this was a problem to do with ssh keys, but I am able to run git pull
myself perfectly fine.
Things I’ve already tried/fixed:
- my SSH key does not have a password
- I have set the
sudoers.h/updateGit
accordingly, so the systemctl restart can be run without a password
Does anyone have any clue what this could be?