Autorun the Faye server when I start the Rails server

前端 未结 4 710
生来不讨喜
生来不讨喜 2020-12-24 03:25

I currently have Faye working with my Rails 3.0.9 application. However I have two separate tabs open in my terminal. One for the Faye server, and one for the Rails server. H

4条回答
  •  臣服心动
    2020-12-24 04:06

    On Ubuntu, you should use the operating systems's init system - Upstart.

    user@host:~$ cat /etc/init/faye.conf 
    description "Faye Upstart script"
    
    start on startup
    stop on shutdown
    
    respawn
    
    script
        env RAILS_ENV=production
    
        exec sudo -u deployuser -i /home/deployuser/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bin/rackup /var/www/booko.com.au/booko/faye.ru -s thin -E production
    end script 
    

    I'm not happy with the method of calling Ruby since it will change. But the advantages are that it will start when the system starts and it will respawn if it dies or you KILL it.

    Let Upstart take care of demonising a process and making sure it keeps running.

提交回复
热议问题