how to use thin-specific cli options in rails server - ruby-on-rails

I'm using thin and launch it through rails server thin. (If I launch thin separately I have 2 logs (rails and thin log) and no stacktraces in some cases.) If I try to launch it with the option -S /var/tmp/thin/thin.sock rails server complains that it's not a valid option.

try switching to thin command:
thin -S=/var/tmp/thin/thin.sock

Related

How to start rails server command as daemon that relaunch after reboot or crush?

I setup Nginx for listening to lockalhost:3000 than I launch rails command bundle exec rails server webrick -e production. I found that I can launch rails server as daemon simply adds the -d flag to the command, so the command becomes a bundle exec rails server -d webrick -e production. My problem is that after server reloads or app is crushed - that a dead-end, I can't found info about how should I create "rails as a daemon with auto relaunch".
webrick in production?
Please please please refrain from doing anything like that. Use puma or unicorn or any similar app server for your purpose.
And for the process monitoring part, you can use systemd, or monit for better control.
Personally, I prefer monit as it gives me crash logs and downtime alerts.

How to enable thin server for faye in production in rails3 for private_pub gem with apache2

I am using private_pub gem for live chat in my rails 3.2 application and it is working perfectly on development mode but I am stuck at how to do it on production.
I am using apache2 in production. When I ran this command on server
RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production
It starts the thin server but my app keeps on waiting for response from
http://www.example.com:9292/faye.js
It doesn't do anything. I am unable to connect with faye in prodution
Thanks for help in advance
Thin and Apache need to be set up running on different ports.
The default settings for both should work, but you should double
check. Ensure apache is running under port 80 and thin is using port
9292. These numbers should be visible when the servers start up.
In the end you should be able to access faye.js at
http://yoursite.com:9292/faye.js and your site at http://yoursite.com/
Source: https://stackoverflow.com/a/6667347/539075

Stuck on "Using Rails Adapter" when starting script with thin

I'm running bundle exec thin -p 4000 -e sandbox start 2>&1 and I get:
>> Using rails adapter
It just hangs there and I don't think that my Rails adapter is running. Does thin have a log or something I can see to find out what's going on?
look at this site
http://code.macournoyer.com/thin/doc/classes/Thin/Logging.html
it has the info you need to log the adapter
Turns out I had to use foreman to start things up and running.

What are the differences between using `rails server` and `rackup`?

The only difference I've noted is that rails server starts the server on port 3000, while rackup starts the server on port 9292.
Are there any other differences?
Are there use cases for one instead of the other?
rails server is the command for starting your server (usually WEBrick) and is in rails.
rackup is a command that comes with the rack middle and uses the settings in your config.ru and starts a server based off of those. This is a standard (it will work for other frameworks and rack-based applications) and is usually used in production servers.
One difference of note is that if you start a server with rails s then you will see the output in the terminal.
In my experience, in production, rackup is used by phusion passenger so you wouldn't want rails s in that situation.
As an aside, the port can be changed with both rails server and rackup using the -p flag.

How to redirect (Rack) Thin server output to console?

Thin server has -l option to redirect output to log file (default: log/thin.log). Is there a way like in webrick server the output is always to console (and log/development.log) too ?
My installed version of Thin automatically outputs to the console. If yours doesn't, you could try updating your installed version.
You could also try thin -l -, which tells Thin to redirect output to STDOUT.
Hope this helps!
If you're using rails, add this to your gemfile:
gem 'thin', :group => 'development'
And then from the console, use:
rails s
This will send logs to standard out and to log/development.log
Don't use "thin start", as some of the docs say.
Mine does automatically output into console however if I use a Procfile, it doesn't.
I use thin start -d to start thin as a background daemon with default logging and send the output of the file back to console with
tail -f log/thin.log
This way the server doesn't stop if terminal closes, but I can see output from puts statements. If you want more detailed logging from thin that's a bit different.
To stop the service/daemon use thin stop
The solution is to add a small code snippet in your config.ru file, and thin output all app logs to the console, without having to tail the log file and it keeps the log coloring intact
Details here: Thin server: Thin server: ouput rails application logs to console, as 'rails s' does

Resources