0

Linux ボックスを再起動するたびに、rails s開発環境で Rails アプリを起動するために実行する必要があります。

Linux の再起動時に特定の Rails アプリを自動的に起動する方法はありますか?

ソリューションは、本番環境でアプリを実行することに近いと思います。

実稼働サイトでアプリを実行したことはありません。

更新 1

この問題について詳しく調べてみたところ、身近なものが見つかりました。起動時に「rc.local」を実行するにはどうすればよいですか? .

私の/etc/rc/local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/askar/.rvm/rubies/ruby-2.1.2/bin/ruby /home/askar/work/rails/smn/bin/rails s

exit 0

$ ls -al /etc/rc.local

-rwxr-xr-x 1 ルート ルート 423 7 月 23 日 12:41 /etc/rc.local

私は次のように実行できます:

$/etc/rc.local &

しかし、次回の起動時に自動的に起動するように実行しようとすると:

sudo /etc/init.d/rc.local start

それは私にエラーを与えています:

Could not find rake-10.2.1 in any of the sources
Run `bundle install` to install missing gems.
4

3 に答える 3

0

bash コマンドを追加するだけです。

cd path/to/rails/project; rails s

~/.bashrcファイルなどのログイン スクリプト。ログイン スクリプトは、Linux ボックスにログインするたびに Rails サーバーを起動します。OSX では、LaunchAgents にログイン項目を追加します。

于 2014-07-22T01:34:28.543 に答える
0

また、Prax https://github.com/ysbaddaden/praxのようなものを見ることもでき ます。 これは、Pow for OSX の純粋な Ruby 代替であり、ラック プロキシとして実行し、sitename.dev でサイトにアクセスできます。複数のサイトを簡単にリンクして名前でアクセスでき、ポートなどを気にする必要がないため、rails s よりもこれが気に入っています。

于 2014-07-22T01:34:55.523 に答える