Question

I am running a jruby project with a puma server and nginx. I run puma using the puma-manager upstart service. Everything works just fine as long as the socket file I have my service set to use has been cleaned up (deleted before trying to start the service). When the socket file does not exist, the service creates it and nginx can see it just fine. However, when stopping/starting or restarting puma, the socket file remains and I get the error: IOError: Connection refused, when trying to connect to the socket. Deleting the socket resolves the problem.

The problem is having to manually delete this socket file is annoying and troublesome in production.

I am using a puma.rb config for start up with state_file and pidfile options set properly. I thought this would correctly handle these files for me. Any suggestions or help on how to delete this socket file each time the server is reset?

Was it helpful?

Solution

It seems, after a bit more searching, that Puma does not have a way of cleaning up its own socket files on shut down in certain instances. When I get a moment, I may add this to the project and send them a pull request. However, I did find a rather simple solution. In the upstart conf file (they provide puma.conf and puma-manager.conf, but you can create your own), before the line which runs the "bundle exec puma" command I have added a check to see if the socket exists. If it does, I remove it. If not, I move on with the bundle exec. Seems to work like a charm.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top