I have a playbook to install puma on my ec2 instance and everything is fine except when I run bundle exec pumactl start at the the end it starts the server but the playbook hangs indefinitely.

Here is the Ansible task -

 - shell: /home/ubuntu/.rbenv/shims/bundle exec pumactl start
     chdir: /home/{{ user }}/{{ app_name }}
     warn: no

Is there a way to avoid this?


I added this to my /etc/systemd/system/puma.service file and ran it with systemd as @Michael suggested -

Description=Puma Rails Server

ExecStart=/bin/bash -lc '/home/ubuntu/.rbenv/shims/bundle exec puma -C /home/ubuntu/my_app/config/puma.rb'
ExecStop=/bin/bash -lc '/home/ubuntu/.rbenv/shims/bundle exec pumactl -S /home/ubuntu/my_app/shared/pids/puma.state stop'


You forgot to daemonize puma, so it's running in the foreground. Ansible has been waiting for it to exit. Add the -d option to the command.

Better yet, you should create a systemd unit to run puma as a service, and then start that service. Daemonizing is not required in that case, as systemd will handle everything.

BTW, it is best practice to use command instead of shell unless you actually need shell processing (which in this case you do not).

| improve this answer | |
  • I originally started looking at using systemd but I couldn't get the configuration right. I finally found what I was doing wrong and updated my question though. Thanks for pointing me in the right direction. – Ryan Grush Jul 25 '18 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.