pm2 在 git hook 中拋出錯誤

pm2 在 git hook 中拋出錯誤

如果呼叫以下 git post-receive 掛鉤,我的伺服器會拋出錯誤:

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

如果將命令一一輸入到終端機中,它將起作用。那我做錯了什麼?

錯誤:

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 是透過 npm install pm2 -g 安裝的,應該由使用者「git」運行。

答案1

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

為我做的。仍然想知道我是否配置錯誤。

相關內容