将 unicorn_init.sh 符号链接到 /etc/init.d 不显示 chkconfig --list

Symlinking unicorn_init.sh into /etc/init.d doesn't show with chkconfig --list

我将我的 config/unicorn_init.sh 符号链接到 /etc/init.d/unicorn_project 与:

sudo ln -nfs config/unicorn_init.sh /etc/init.d/unicorn_<project>

之后,当我 运行 chkconfig --list 我的 unicorn_ 脚本没有显示。我正在添加我的独角兽脚本以在服务器负载上加载我的应用程序。

显然,这不允许我添加我的脚本:

chkconfig unicorn_<project> on

任何帮助/建议都很棒 :)。

编辑:

此外,当我在 /etc/init.d/ 和 运行:

sudo service unicorn_project start

上面写着:"unrecognized service"

我想通了。我做的有两件事不对:

1) 您必须通过在 #!/bin/bash 下面添加以下代码来确保您的 unicorn 脚本可以很好地与 chkconfig 配合使用。支持 digitalocean's blog 寻求帮助。

# chkconfig:   2345 95 20
# description: Controls Unicorn sinatra server
# processname: unicorn

2) 当我已经在项目目录中时,我试图通过使用相对路径对 config/unicorn_init.sh 文件进行符号链接,该目录正在创建悬空符号链接(粉红色符号链接 ~> 应该是蓝绿色) .为了解决这个问题,我删除了悬挂的符号链接并提供了 unicorn_init.sh 文件的绝对路径。

为了调试这个,我在 /etc/init.d/ 目录中使用了 ll 来查看 r、w、x 权限和文件类型,是 运行ning chkconfig --list查看 /etc/init.d/ 中的服务列表,还试图 运行 我的 /etc/init.d 目录中的悬挂符号链接 sudo service unicorn_<project> restart

希望这对某人有所帮助。