Heroku:"bash:./ start.sh:Permission denied"

Nif*_*255 9 bash shell heroku node.js procfile

我有一个应用程序,其中Procfile设置为运行shell脚本,但Heroku不会运行脚本,说明"权限被拒绝".

Procfile:

web: ./start.sh
Run Code Online (Sandbox Code Playgroud)

start.sh:

#!/usr/bin/env bash
clear;
until node app.js; do
    echo "Server crashed with exit code $?.  Respawning.." >&2
    sleep 1
done
Run Code Online (Sandbox Code Playgroud)

Heroku日志:

Starting process with command './start.sh'
bash: ./start.sh: Permission denied
State changed from starting to crashed
Process exited with status 126
Run Code Online (Sandbox Code Playgroud)

ric*_*ici 11

为了工作,start.sh必须是可执行的:

chmod a+x start.sh
Run Code Online (Sandbox Code Playgroud)

如果你不能安排在运行文件的机器上发生这种情况,你可以直接用bash调用它; 而不是./start.sh,使用bash ./start.sh(甚至只是bash start.sh)

  • 使用bash ./start.sh可以工作。谢谢。 (2认同)