Reputation: 18560
I'm trying to set up a system that automatically pulls and compiles on a remote server when I push to a repository on GitHub. I've found a number of very useful things in getting this working, but I'm stuck with the last step: executing my task, gulp --dist
.
I'm using this excellent PHP script to trigger the pull, which works great. I've forked that repository in order to try to add an additional option, AFTER_PULL
, which executes a shell command after pulling finishes. Here's my modification (also below). In config.php, I'm setting the following:
define('AFTER_PULL', 'node ./node_modules/gulp/bin/gulp.js --dist');
That doesn't seem to ever fire, and no error seems to be triggered either.
I'm thinking it's probably a permissions thing, but the user (www-data) has permission to work in all the directories necessary. I found this article detailing how to allow www-data to run without needing a password, but after completing these steps, it's still not working.
I'm sure I must be doing something obviously wrong and I'm just unable to see it. The command works if I run it in a terminal with sudo -Hu www-data
.
...
if (!empty(AFTER_PULL)) {
try{
shell_exec(AFTER_PULL);
}catch (Exception $e) {
fputs($file, $e . "\n");
}
}
...
Upvotes: 1
Views: 860
Reputation: 741
Use the full path to node binary:
define('AFTER_PULL', ' /usr/bin/node ./node_modules/gulp/bin/gulp.js --dist');
Upvotes: 2