Ghost开机启动

Ghost本身是基于node.js的,这意味着 – 常驻后台需要用到其他方式,例如&或者forever官网建议

但这样也需要使用类似sudo start_ghost.sh这种方式来启动,想开机启动的话还是需要使用update-rc.d或者cron

前者官网提供了一个说明,相当于自己写一个service

后者比较强大,用在这里有点大材小用。

简单点的做法就直接参考stackoverflow

sudo mv /filename /etc/init.d/
sudo chmod +x /etc/init.d/filename 
sudo update-rc.d filename defaults 

Script should now start on boot. Note that this method also works with both hard links and symbolic links (ln).

Edit

At this point in the boot process PATH isn’t set yet, so it is critical that absolute paths are used throughout. BUT, as pointed out in the comments by Steve HHH, explicitly declaring the full file path (/etc/init.d/filename) for the update-rc.d command is not valid in most versions of Linux. Per the manpage for update-rc.d, the second parameter is a script located in /etc/init.d/*. Updated above code to reflect this.

Another Edit

Also as pointed out in the comments (by Charles Brandt), /filename should be an init style script. A good template was also provided - https://github.com/fhd/init-script-template.

Another link to another article just to avoid possible link rot (although it would be saddening if GitHub died) - http://www.linux.com/learn/tutorials/442412-managing-linux-daemons-with-init-scripts

不仅给出了回答,可能的坑,还给出了标准service的模版。。。

stackoverflow果然神站啊~~

简单记录一下,算是ghost安装必备流程之一吧。