简体   繁体   English

从启动rails服务器开始

[英]Starting on boot a rails server

I'm using Ubuntu Server and I have a rails application. 我正在使用Ubuntu Server,我有一个rails应用程序。 I want to start the rails server on the boot. 我想在启动时启动rails服务器。 I've already put the files on the /etc/init.d/ and also I've created a crontab with the command: 我已经将文件放在/etc/init.d/上了,我也用命令创建了一个crontab:

cd ~/myapp/ nohup rails s -p 8000 & cd~ / myapp / nohup rails s -p 8000&

I've already used Puma Server(https://github.com/puma/puma/) but I cannot start the server. 我已经使用过Puma Server(https://github.com/puma/puma/),但我无法启动服务器。 If I execute the script manually, so the server started perfectly. 如果我手动执行脚本,那么服务器就会完美启动。 I don't know how it is happening. 我不知道它是怎么回事。 Someone has been passed something similar to this? 有人通过类似的东西吗?

You have to create a link to the /etc/rc2.d/ directory like this: 您必须创建一个指向/etc/rc2.d/目录的链接,如下所示:

ln -s /etc/init.d/name_of_yout_script.sh /etc/rc2.d/S123_rails_server.sh

Because /etc/init.d/ is the place where starter scripts are stored but the /etc/rc2.d/ folder is the one which contains the scripts that are executed when starting up. 因为/etc/init.d/是存储启动脚本的地方,但/etc/rc2.d/文件夹是包含启动时执行的脚本的文件夹。 By using S_name.sh you say via the number at which position a script is runned. 通过使用S_name.sh,您可以通过运行脚本的位置编号来说明。 The higher the number the later it is executed. 执行的越晚,数字越大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM