Faye / Thin

32 views
Skip to first unread message

Nader

unread,
Mar 29, 2012, 4:10:55 PM3/29/12
to Moonshine
Hey All,

I have a Rails 3.1 app that I will be deploying over the weekend.
There is a real-time notification portion of the application that is
using Backbone JS / Faye via Thin. I was just wondering if there were
any precautions / certain steps I should take to get this all working
on a pristine Linode VPS using Moonshine?

Faye: http://faye.jcoglan.com/
Thin: http://code.macournoyer.com/thin/

Thanks so much, Moonshine has been extremely integral in getting a
number of applications up and running over the past 2 years.

-Nader

Josh Nichols

unread,
Mar 29, 2012, 5:12:04 PM3/29/12
to moonshine
Hi Nader,

For the faye side of things, you'll want to use god (ie via moonshine_god) to manage the faye-server (ie starting and stopping, restarting on deploy, etc). I've used this particular config, stashed in config/god/faye.god. You'll want to replace YOURAPP with the name of your app :)

--------

God.watch do |w|
w.name = "faye-server-0"
w.group = "YOURAPP-faye"
w.interval = 30.seconds
w.log = File.join(RAILS_ROOT, 'log', "#{w.name}.god.log")
w.uid = 'rails'
w.gid = 'rails'
w.env = { 'RAILS_ENV' => RAILS_ENV }
w.dir = RAILS_ROOT
w.start = "bundle exec rackup faye/server.rb"

# restart if memory gets too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.above = 300.megabytes
c.times = 2
end
end

# determine the state on startup
w.transition(:init, { true => :up, false => :start }) do |on|
on.condition(:process_running) do |c|
c.running = true
end
end

# determine when process has finished starting
w.transition([:start, :restart], :up) do |on|
on.condition(:process_running) do |c|
c.running = true
c.interval = 5.seconds
end

# failsafe
on.condition(:tries) do |c|
c.times = 5
c.transition = :start
c.interval = 5.seconds
end
end

# start if process is not running
w.transition(:up, :start) do |on|
on.condition(:process_running) do |c|
c.running = false
end
end
end

> --
> You received this message because you are subscribed to the Google Groups "Moonshine" group.
> To post to this group, send email to railsmachin...@googlegroups.com.
> To unsubscribe from this group, send email to railsmachine-moon...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/railsmachine-moonshine?hl=en.
>

Reply all
Reply to author
Forward
0 new messages