我有一个非常简单的 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 有什么问题无法正确启动脚本?