I don't know if this is a stupid question or not, but how do I keep my puma server for my rails app running without having the puTTy window open to my ec2 instance? I'd like to have it fired up and then close the window and not have my PC on all the time.
Asked
Active
Viewed 431 times
2 Answers
1
You can use screen
- Login to your server using putty
- Type
screen
- Run your server
- Do ctrl-a and then press d
- Now your server is running in the background and you can disconnect from putty!
To resume the process(see the actual console)
- Do
screen -ls
- Do
screen -r <screen_name>
Note that all screen processes will be killed on server restart

Tudor
- 320
- 1
- 9
-
Hot damn, thanks man! that worked, I'm up and running! – Joseph Harskamp Jan 18 '18 at 15:47
1
To keep puma server running in EC2, you've to daemonize it i.e. run it in background.
If you're using puma, you should have config/puma.rb
file with daemonize true for non development environment. Your puma.rb
file should look like
railsenv = ENV.fetch("RAILS_ENV") { "development" }
environment railsenv
if railsenv != "development"
application_path = '/home/ubuntu/hybrid'
daemonize true
directory application_path
pidfile "#{application_path}/tmp/pids/puma-#{railsenv}.pid"
state_path "#{application_path}/tmp/pids/puma-#{railsenv}.state"
stdout_redirect "#{application_path}/log/puma-#{railsenv}.stdout.log", "#{application_path}/log/puma-#{railsenv}.stderr.log"
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
end
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
port ENV.fetch("PORT") { 3000 }
Now you can start it as bundle exec pumactl -F config/puma.rb start
. You can similarly stop
or restart
the puma server.

Anurag Aryan
- 611
- 6
- 16