0

My Server throws an error if the following git post-receive hook is called:

#!/bin/sh # pm2 start main.js --name powerapp 

If the command is entered by one by one into the terminal it will work. So what am I doing wrong?

Error:

remote: fs.js:642 remote: return binding.mkdir(pathModule._makeLong(path), remote: ^ remote: Error: EACCES, permission denied '/etc/.pm2' remote: at Object.fs.mkdirSync (fs.js:642:18) remote: at Object.CLI.pm2Init (/home/nodejs/.local/lib/node_modules/pm2/lib/CLI.js:39:8) remote: at Object.<anonymous> (/home/nodejs/.local/lib/node_modules/pm2/bin/pm2:21:5) remote: at Module._compile (module.js:456:26) remote: at Object.Module._extensions..js (module.js:474:10) remote: at Module.load (module.js:356:32) remote: at Function.Module._load (module.js:312:12) remote: at Function.Module.runMain (module.js:497:10) remote: at startup (node.js:119:16) remote: at node.js:901:3 

pm2 was installed via npm install pm2 -g and should run by the user 'git'.

2
  • What is the home directory of the git user? Likely it's /etc, but that's a bad idea, because no one except root should be allowed to create files in there. Commented Sep 26, 2015 at 14:53
  • In the terminal echo $HOME tells '/var/opt/gitlab'. But if I try #!/bin/bash # echo $HOME in my post-receive hook there is an empty result. Guess I messed something up with my home folder. Commented Sep 26, 2015 at 15:57

1 Answer 1

0
export PM2_HOME='/var/opt/gitlab/.pm2' 

did it for me. Still wondering if I misconfigured something.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.