https://medium.com/@rdsubhas/ruby-in-production-lessons-learned-36d7ab726d99
-
Install foreman gem to manage processes
web: rails server
-
Type following command from inside the project directory:-
$ sudo foreman export --app app_name --user prashant upstart /etc/init
$ ls /etc/init/app_name*
$ ls /var/log/app_name/
In this way out app is on par with a core system service. We don’t have to dabble with PID files, system handles that. The OS will automatically reboot service if it crashes, rotate logs.
More info: http://stackoverflow.com/questions/12990842/how-to-use-foreman-to-export-to-upstart
-
This gem redirects log in production to stdout, from there we can manage the log through OS or use any log aggregation service like papertrail gem.
-
It enables rails app server to serve static assets which is actually giving more control to rails app server. This is usually managed through reverse proxy server like Ngnix/Apache.
It basically enables this flag config.serve_static_assets = true
https://github.com/rdsubhas/ruby-deploy-kickstart
https://pooreffort.com/blog/better-rails-logging/
Improved Rails logging - very nice gem https://github.com/roidrage/lograge
unless Rails.env.test?
log_level = String(ENV['LOG_LEVEL'] || "info").upcase
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(log_level)
config.log_level = log_level
#config.lograge.enabled = true # see lograge section below...
end
http://ddollar.github.io/foreman/
http://stackoverflow.com/questions/4883891/ruby-on-rails-production-log-rotation
http://rubyjunky.com/cleaning-up-rails-4-production-logging.html