I have modified a version of this github project https://github.com/lkwdwrd/git-deploy [I modified it as for some reason JSON wasnt being parsed on my server (Mediatemple Grid Server) & I also added custom logging] The script autodeploys github repos using git hooks.
The script was working fine for a while but recently stopped working.
I've isolated the problem to the git fetch command. This the exact code I'm using:
exec( 'git fetch ' . $this->_remote . ' ' . $this->_branch, $fetch_output, $fetch_return_var );
The $fetch_output array is blank and the $fetch_return_var is 255. So I believe that the 255 really means -1, which is an error with the git command.
However I am able to successfully execute this command when SSH'd into the server and running as the same user with the exact same string as is being build as the 1st argument of the exec() function.
So now I'm lost.
- Is there an effective difference between running commands manually via SSH and using exec()?
- Is there any way I can get the actual git fetch error that is being returned to exec()?
- Could this be some kind of server configuration that has been changed by my host and that I should contact them for?
thanks in advance
UPDATE:
Thanks to @Matthias Huttar I changed my exec() to a proc_open() call that allowed me to see the output of STDERR [not sure why it was not logging thru exec() but I think it is because it was a subprocess of git fetch]. This output is:
error: cannot fork() for git-remote-https: Resource temporarily unavailable
So I think there is an issue with my server environment. However I'm still not certain.