Skip to content

Instantly share code, notes, and snippets.

@mateusmedeiros
Last active August 16, 2017 14:09
Show Gist options
  • Save mateusmedeiros/0d1940321a444d918dce to your computer and use it in GitHub Desktop.
Save mateusmedeiros/0d1940321a444d918dce to your computer and use it in GitHub Desktop.
Systemd services
[Unit]
Description=App running with puma + improvised rvm gemset support
[Service]
RootDirectory=/srv/http
WorkingDirectory=/www/doodad
User=http
Group=http
EnvironmentFile=/etc/systemd/system/doodad.vars
ExecStart=/home/http/.rvm/rubies/rbx-2.2.5/bin/ruby -rubygems -Ilib /home/http/.rvm/gems/rbx-2.2.5@mateusmedeiros/bin/puma -b unix://tmp/puma/socket --pidfile tmp/puma/pid --state tmp/puma/state -t 4:32 config.ru
[Install]
WantedBy=multi-user.target
Note:
File referenced on doodad.service, has variables needed for rvm and RACK_ENV (well, I said it was improvised), but the app uses a rvm gemset
---------------------- begin file -------------------------
LANG=pt_BR.UTF-8
rvm_bin_path=/home/http/.rvm/bin
GEM_HOME=/home/http/.rvm/gems/rbx-2.2.5@mateusmedeiros
IRBRC=/home/http/.rvm/rubies/rbx-2.2.5/.irbrc
MY_RUBY_HOME=/home/http/.rvm/rubies/rbx-2.2.5
USER=http
rvm_path=/home/http/.rvm
rvm_prefix=/home/http
PATH=/home/http/.rvm/gems/rbx-2.2.5@mateusmedeiros/bin:/home/http/.rvm/gems/rbx-2.2.5@global/bin:/home/http/.rvm/rubies/rbx-2.2.5/bin:/home/http/.rvm/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/bin
HOME=/home/http
RACK_ENV=production
RUBY_VERSION=rbx-2.2.5
GEM_PATH=/home/http/.rvm/gems/rbx-2.2.5@mateusmedeiros:/home/http/.rvm/gems/rbx-2.2.5@global
[Unit]
Description=fcgiwrap + spawn-fcgi + multiwatch + chroot and non-root user (not through systemd but through spawn-fcgi -u, -g and -c options)
After=nss-user-lookup.target
[Service]
WorkingDirectory=/srv/http
ExecStart=/usr/bin/spawn-fcgi -c /srv/http -u http -g http -s /run/fcgiwrap.sock -P /run/fcgiwrap.pid -n -- /usr/bin/multiwatch -f 10 -- /usr/sbin/fcgiwrap
ExecStartPost=/usr/bin/chmod 660 run/fcgiwrap.sock
ExecStop=/usr/bin/kill -15 $MAINPID
PrivateTmp=true
Restart=on-failure
[Install]
WantedBy=multi-user.target
[Unit]
Description=Nginx + non-root user + chroot
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/srv/http/run/nginx.pid
RootDirectory=/srv/http
WorkingDirectory=/
User=http
Group=http
ExecStartPre=/usr/bin/nginx -t -q -g 'pid /run/nginx.pid; daemon on; master_process on;'
ExecStart=/usr/bin/nginx -g 'pid /run/nginx.pid; daemon on; master_process on;'
ExecReload=/usr/bin/nginx -g 'pid /run/nginx.pid; daemon on; master_process on;' -s reload
ExecStop=/usr/bin/nginx -g 'pid /run/nginx.pid;' -s quit
[Install]
WantedBy=multi-user.target
[Unit]
Description=Postgresql + chroot
[Service]
Type=forking
RootDirectory=/srv/http
WorkingDirectory=/
User=postgres
Group=postgres
ExecStartPre=/bin/bash -c "mkdir -p /run/postgresql"
ExecStart=/usr/bin/pg_ctl start -D /var/lib/postgres/data
ExecStop=/usr/bin/pg_ctl stop -D /var/lib/postgres/data
[Install]
WantedBy=multi-user.target
[Unit]
Description=Redmine + improvised bundle support + non-root user + chroot
After=postgres.service
Requires=postgres.service
[Service]
RootDirectory=/srv/http
WorkingDirectory=/www/redmine
User=redmine
Group=http
EnvironmentFile=/etc/systemd/system/redmine.vars
ExecStart=/home/http/.rvm/rubies/rbx-2.2.5/bin/ruby -rubygems -Ilib /home/http/.rvm/gems/rbx-2.2.5@global/bin/bundle exec puma -b unix://tmp/puma/socket --pidfile tmp/puma/pid --state tmp/puma/state -t 4:32 config.ru
[Install]
WantedBy=multi-user.target
Note:
File referenced on redmine.service, has variables needed for rvm and RACK_ENV (well, I said it was improvised).
---------------------- begin file -------------------------
LANG=pt_BR.UTF-8
rvm_bin_path=/home/http/.rvm/bin
GEM_HOME=/home/http/.rvm/gems/rbx-2.2.5
IRBRC=/home/http/.rvm/rubies/rbx-2.2.5/.irbrc
MY_RUBY_HOME=/home/http/.rvm/rubies/rbx-2.2.5
USER=http
rvm_path=/home/http/.rvm
rvm_prefix=/home/http
PATH=/home/http/.rvm/gems/rbx-2.2.5/bin:/home/http/.rvm/gems/rbx-2.2.5@global/bin:/home/http/.rvm/rubies/rbx-2.2.5/bin:/home/http/.rvm/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/bin:/usr/bin/core_perl
HOME=/home/http
RUBY_VERSION=rbx-2.2.5
RACK_ENV=production
GEM_PATH=/home/http/.rvm/gems/rbx-2.2.5:/home/http/.rvm/gems/rbx-2.2.5@global
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment