Skip to content

Instantly share code, notes, and snippets.

@cloudrck
Forked from AlexeyDemidov/defaults_unicorn_app
Created April 22, 2017 02:22
Show Gist options
  • Save cloudrck/ba479381a26b877c97d43c677eebd2d5 to your computer and use it in GitHub Desktop.
Save cloudrck/ba479381a26b877c97d43c677eebd2d5 to your computer and use it in GitHub Desktop.
Unicorn service file for systemd with rvm support
# save this file in /etc/default/unicorn_app
USER=app_user
APP_ROOT=/srv/app
RVM_STRING=2.2.4@app_gemset
RACK_ENV=production
UNICORN_OPTS="-D -c /srv/app/shared/config/unicorn.rb -E production"
DAEMON=unicorn
[Unit]
# You can create multiple unicorn service by linking [email protected] to [email protected], [email protected]
# each application reads its settings from /etc/default/unicorn_appone, /etc/default/unicorn_apptwo
Description=Unicorn serving %I app
After=syslog.target
[Service]
Restart=always
RestartSec=10
Type=forking
WorkingDirectory=/srv/%I/current
EnvironmentFile=/etc/default/unicorn_%I
SyslogIdentifier=unicorn-%I
PIDFile=/srv/%I/shared/pids/unicorn.pid
KillMode=mixed
KillSignal=SIGQUIT
User=%I
ExecStart=/usr/local/rvm/bin/rvm-shell ${RVM_STRING} -c "bundle exec ${DAEMON} ${UNICORN_OPTS}"
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment