startup script

44 views
Skip to first unread message

Jay Amorin

unread,
Feb 27, 2014, 10:52:59 AM2/27/14
to rubyonra...@googlegroups.com
Hi,

I just started ruby on rails. Would it be possible to create a start script that I can use on boot?

/etc/init.d/my_rails_init_script.sh {start|stop}

I've search the web and I can't find any.

Thanks,


Jay

Walter Lee Davis

unread,
Feb 27, 2014, 10:59:59 AM2/27/14
to rubyonra...@googlegroups.com
Generally, you only start the Rails application directly if you're hosting it locally, for development purposes. For all other forms of deployment (public) you would have a Web server to front-end requests and pass them along to your Rails app, which would be running in Passenger or Thin or another application server. That would be the thing you would start, not Rails itself. In the case of Passenger, it starts when Apache does, and keeps Rails hot and ready to receive requests as long as Apache is running.

Starting up Apache or Nginx at system boot is a really well-soved problem, you would probably have a harder time getting it to _not_ start at boot.

Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2ef2cd6a-cc07-475b-a938-25026f1d4208%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Hassan Schroeder

unread,
Feb 27, 2014, 12:07:52 PM2/27/14
to rubyonrails-talk
On Thu, Feb 27, 2014 at 7:59 AM, Walter Lee Davis <wa...@wdstudio.com> wrote:
> For all other forms of deployment (public) you would have a Web server to front-end requests and pass them along to your Rails app, which would be running in Passenger or Thin or another application server.

Yes, and that "another application server" needs to be started, so --
not sure what your point is.

To the OP - one app server, Puma, comes with an init.d script; you
might get some ideas from that even if you choose another server.

( See <https://github.com/puma/puma> under 'tools' )

Good luck,
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassa

Walter Lee Davis

unread,
Feb 27, 2014, 12:17:24 PM2/27/14
to rubyonra...@googlegroups.com
My point is that "starting rails" at system start smells of someone trying to host production in Webrick.

Walter

Colin Law

unread,
Feb 27, 2014, 12:26:07 PM2/27/14
to rubyonra...@googlegroups.com
On 27 February 2014 15:52, Jay Amorin <jeey...@gmail.com> wrote:
> Hi,
>
> I just started ruby on rails. Would it be possible to create a start script
> that I can use on boot?
>
> /etc/init.d/my_rails_init_script.sh {start|stop}

Can you explain why you want to do this? It is a bit unusual for
someone just starting rails to want a server running from boot,
assuming that is what you mean to achieve.

What would be in the startup script to start the server?

Colin


>
> I've search the web and I can't find any.
>
> Thanks,
>
>
> Jay
>

Jay Amorin

unread,
Feb 27, 2014, 11:33:05 PM2/27/14
to rubyonra...@googlegroups.com
I just want that every time i restart my server, rails would also be up and running. No need for me to login and cd to your rails apps and then type rails server.

I already did those cool stuff, nginx proxy on the frontend, rails on the backend.

The thing is my current rails don't comes with a startup/init script. I hope that someone already did that and would like to share.

Jay


Frederick Cheung

unread,
Feb 28, 2014, 6:31:35 AM2/28/14
to rubyonra...@googlegroups.com
On Friday, February 28, 2014 4:33:05 AM UTC, Jay Amorin wrote:
I just want that every time i restart my server, rails would also be up and running. No need for me to login and cd to your rails apps and then type rails server.

I already did those cool stuff, nginx proxy on the frontend, rails on the backend.

The thing is my current rails don't comes with a startup/init script. I hope that someone already did that and would like to share.

 
Typically people don't use `rails server` in production, which is probably why you haven't found any examples of that. You're more likely to use something like unicorn, puma, passenger (either the standalone version or the nginx/apache module version) and you shouldn't have trouble finding startup scripts for those.

Fred

Carlos Figueiredo

unread,
Feb 28, 2014, 9:28:31 AM2/28/14
to rubyonra...@googlegroups.com
I can not figure out why it can not be done... if you put a symbolic link for your ruby binary, you just need to do something like

/etc/init.d/start_fancy_ruby_script.sh

# /bin/ruby
#
puts "Your fancy script works"

  


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

Carlos Figueiredo

unread,
Feb 28, 2014, 9:34:30 AM2/28/14
to rubyonra...@googlegroups.com
Oh sorry... only now I figured out that I was answering on a rails group... so it could be about a rails app that you need to start with init.d

In that case... you can also use a script.. but it is a more complicated one...
 
As recommended above, it's better use passenger or unicorn... 

Jay Amorin

unread,
Feb 28, 2014, 9:54:01 AM2/28/14
to rubyonra...@googlegroups.com
Now I get it. Thanks guys for pointing me to the right direction.

Jay


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

Phillip

unread,
Feb 28, 2014, 3:51:43 PM2/28/14
to rubyonra...@googlegroups.com

www.phusionpassenger.com
Reply all
Reply to author
Forward
0 new messages