部署 怎么把 rails s 添加成服务,开机自启动

yakczh · 2014年08月21日 · 最后由 yakczh 回复于 2014年08月22日 · 3586 次阅读

是不是要写个 shell 脚本

export RAILS_ENV=production rails s

服务器是 centos6.5

你用什么服务器?thin,rainbows?

rails s 应该就是 webrick。楼主真要这么干?还是换 thin 或者 puma 吧,或者省事点 apache+passenger

https://github.com/gitlabhq/gitlabhq/blob/master/lib/support/init.d/gitlab 参考一下 gitlab

Download the init script (will be /etc/init.d/gitlab):

sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
And if you are installing with a non-default folder or user copy and edit the defaults file:

sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab

If you installed GitLab in another directory or as a user other than the default you should change these settings in /etc/default/gitlab. Do not edit `/etc/init.d/gitlab as it will be changed on upgrade.

Make GitLab start on boot:

sudo update-rc.d gitlab defaults 21

#2 楼 @jimrokliu yum 安装只有 thin 和 passenger

LoadModule passenger_module modules/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.21 PassengerRuby /usr/bin/ruby 换了 passenger,明显比 webrick 快多了 thin 和 rainbow 相对 passenger 有什么优势吗?

#6 楼 @yakczh thin 是单线程的,异步 IO,类似 nodejs,内存消耗比较小,适合小内存环境。passenger 是多进程并发,适合对线程不安全的代码。

#7 楼 @jimrokliu rainbow 和 puma 呢?

#8 楼 @yakczh puma 是多线程的服务器,占用内存更响,但 MRI ruby 的多线程只能跑单核,所以 puma 建议使用 jruby。

gem install rainbows WARNING: RubyGems 1.2+ index not found for:

RubyGems will revert to legacy indexes degrading performance. ERROR: Could not find a valid gem 'rainbows' (>= 0) in any repository

需要 登录 后方可回复, 如果你还没有账号请 注册新账号