【发布时间】:2013-12-12 14:44:25
【问题描述】:
我有一个非常简单的 bash 脚本,它应该可以启动我的 ghost 博客。我正在使用crontab 在启动时启动脚本,这是我正在运行的 crontab 命令:
@reboot /var/www/ghost/launch.sh
脚本代码如下:
#!/bin/sh
ps auxw | grep apache2 | grep -v grep > /dev/null
if [ $? != 0 ]
then
NODE_ENV=production forever start --sourceDir /var/www/ghost index.js
fi
当我sudo reboot 服务器并使用forever list 查找正在运行的进程时,我看到以下内容:
data: [0] sHyo /usr/bin/nodejs index.js 1299 1314 /home/webadmin/.forever/sHyo.log 0:0:1:25.957
当我nano 到该日志文件时,日志显示以下内容:
^[[31m
ERROR:^[[39m ^[[31mCould not locate a configuration file.^[[39m
^[[37m/home/webadmin^[[39m
^[[32mPlease check your deployment for config.js or config.example.js.^[[39m
Error: Could not locate a configuration file.
at checkTemplate (/var/www/ghost/core/config-loader.js:16:36)
at Object.cb [as oncomplete] (fs.js:168:19)
error: Forever detected script was killed by signal: null
它似乎正在查看/home/webadmin/,但ghost 安装在/var/www/ghost????
当我在服务器通过ssh-ing 启动服务器后手动在终端中运行完全相同的脚本时,脚本工作正常。我运行:cd /var/www/ghost/,然后运行./launch.sh,幽灵博客出现并且运行良好。该forever 进程的日志显示如下:
^[[32mGhost is running...^[[39m
Your blog is now available on http://blog.example.com ^[[90m
Ctrl+C to shut down^[[39m
我的脚本或 crontab 有什么问题导致无法正常启动脚本?
【问题讨论】:
标签: node.js bash crontab forever ghost-blog