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.
Related
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.
I have a Rails application running in Ruby 2.0.0 and Rails 3.2.16. I'm using Sidekiq for setting up background jobs for a lot of automated processes like email delivery, cancellation etc.
Now, I'm starting the rails in one terminal and in next I'm starting the sidekiq.
Rails: rails server -e production
Sidekiq: bundle exec sidekiq -q critical, -q high, -q default, -q low -e production
But, I need to know whether we can start Sidekiq when we start rails itself not running the second command.
Any help would be appreciated. Thanks :)
Look in to foreman and using a Procfile. Then you would use the command foreman start
Here's what my Procfile looks like:
web: bundle exec rails server thin -p $PORT -e $RACK_ENV
worker: bundle exec rake jobs:work
I intend to add a worker process because I wish to run some background jobs. I'm following these instructions
This is what I noticed:
No problems encountered if the worker is started separately.
When I keep the second line in the Procfile and don't not change anything else, the rails server serves a couple of requests and hangs after that
As mentioned here , I've added STDOUT.sync = true to config/environments/development.rb and verified the same in the rails console. Did not work.
Tailed log/development.log and compared it against the stuff that foreman outputted to the shell and noticed that both matched for a couple of requests and then foreman stopped printing out stuff to the shell - the next request would then hang
I updated foreman using foreman.pkg as mentioned here and verified the same with [6]
It was mentioned here that this might be caused due to a stray debug statement. I'm not using the debugger and I do not have the pry gem or the ruby-debug gem in my Gemfile.lock
I believe the symptoms are similar to this related unanswered question
Please help!
[6]:
which foreman
/usr/bin/foreman
ls -lah /usr/bin/foreman # checked the updated date
Tracked and resolved here:
https://github.com/ddollar/foreman/issues/244
TL;DR: Install the gem, don't use foreman.pkg
I'll add than if you're using Heroku, the foreman version included with the heroku toolbelt has the same issue.
Use the one you can get with gem install foreman instead.
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
I'm running Teambox (a Ruby on Rails app) and have the server running with:
script/server -e production
Knowing absolutely nothing about Ruby on Rails I just wandered how I could restart the server to get it to update changes I've made to the config?
If you ran it with that command line it's probably running actively in the console, just CTRL+C.
If you ran it daemonize you will need to find the process and kill it.