Last Updated: February 25, 2016
· jeroenj

Daemonize puma with launchd on Mac OSX with RVM

First set up your application in an rvm gemset:

rvm 1.9.3@my_app --create

Make sure you have puma installed in that gemset. You may also want to add it to your Gemfile, but that step is not required:

gem install puma


gem 'puma'

in your Gemfile.

Next you'll have to create an rvm wrapper for your puma executable so the correct gemset gets loaded from launchd:

rvm wrapper 1.9.3@my_app my_app puma

This will generate a myapppuma executable in /Users/your_username/.rvm/bin/expenses_puma.

Now you have to set up your Launch Agent in ~/Library/LaunchAgents/com.aname.myapp.plist. You have to add the following to that file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Now you'll have to load your Launch Agent by running the following command in your Terminal:

launchctl load -w ~/Library/LaunchAgents/com.jeroen.expenses.plist

You may set a port or pass any other configuration option in the ProgramArguments array.