Reputation: 8078
I am using the gith to build a webhook server on the amazon server to automate the deployment. When I updated my repository, the gith server can receive the update, then I want to execute the bash.
The bash file is on the path of /home/ubuntu/node/githook/hook.sh, console.log(__dirname+'/hook.sh');
output the right path, but when using the execFile to execute the path, it gave a error
error { [Error: spawn EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }
The code is above, but don't know why executing the code gave me such error.
var gith = require('gith').create( 8080 );
var execFile = require('child_process').execFile;
gith({
repo: 'heroku/node-js-sample'
}).on( 'all', function( payload ) {
if( payload.branch === 'master' )
{
//console.log('all',payload );
console.log(__dirname+'/hook.sh');
execFile(__dirname+'/hook.sh', function(error, stdout, stderr) {
// Log success in some manner
if(error) console.log("error",error);
else console.log( 'exec complete',stdout );
});
}
});
Upvotes: 1
Views: 633
Reputation: 48003
You have to make your bash script executable. Use this :
chmod +x hook.sh
Upvotes: 3