Skip to content

Instantly share code, notes, and snippets.

@anon987654321
Last active June 11, 2020 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anon987654321/99becb9e75d235ce10b3490317eaff9e to your computer and use it in GitHub Desktop.
Save anon987654321/99becb9e75d235ce10b3490317eaff9e to your computer and use it in GitHub Desktop.

/etc/rc.d/coolest_app_ever

Commandline works fine:

# doas -u apps sh -c 'cd /home/apps/coolest_app_ever ; /home/apps/.gem/bin/bundle exec
    /home/apps/.gem/bin/pumactl --config-file /home/apps/coolest_app_ever/config/puma.rb start'
Puma starting in single mode...
* Version 4.3.3 (ruby 2.6.6-p146), codename: Mysterious Traveller
* Min threads: 0, max threads: 16
* Environment: production
* Listening on tcp://127.0.0.1:8003
* Listening on ssl://127.0.0.1:8004?key=config/ssl/coolest_app_ever.key&cert=config/ssl/coolest_app_ever.crt
Use Ctrl-C to stop
#!/bin/sh

# http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/infrastructure/templates/rc.template?rev=1.12&content-type=text/x-cvsweb-markup

# Define PATH explicitly to give Bundler access to already installed gems (doesn't work)
daemon="doas -u apps sh -c 'cd /home/apps/coolest_app_ever ; export PATH=/home/apps/.gem/bin/:/bin:/usr/bin:
    /usr/local/bin ; env ; /home/apps/.gem/bin/bundle exec /home/apps/.gem/bin/pumactl --config-file
    /home/apps/coolest_app_ever/config/puma.rb'"

rc_bg=YES

. /etc/rc.d/rc.subr

rc_start() {
  ${rcexec} "${daemon} start"
}

[...]

rc_cmd $1
# rcctl -d start coolest_app_ever
doing _rc_parse_conf
doing _rc_quirks
coolest_app_ever_flags empty, using default ><
doing _rc_parse_conf /var/run/rc.d/coolest_app_ever
doing _rc_quirks
doing rc_check
LOGNAME=apps
DOAS_USER=apps
HOME=/home/apps
OLDPWD=/home/apps
PWD=/home/apps/coolest_app_ever
PATH=/home/apps/.gem/bin/:/bin:/usr/bin:/usr/local/bin
SHELL=/usr/local/bin/zsh
TERM=xterm
USER=apps
Could not find rake-13.0.1 in any of the sources
Run `bundle install` to install missing gems.
coolest_app_ever
doing rc_start
doing _rc_wait start
doing rc_check
LOGNAME=apps
LOGNAME=apps
DOAS_USER=apps
HOME=/home/apps
OLDPWD=/home/apps
PWD=/home/apps/coolest_app_ever
PATH=/home/apps/.gem/bin/:/bin:/usr/bin:/usr/local/bin
SHELL=/usr/local/bin/zsh
TERM=xterm
USER=apps
DOAS_USER=apps
HOME=/home/apps
OLDPWD=/home/apps
PWD=/home/apps/coolest_app_ever
PATH=/home/apps/.gem/bin/:/bin:/usr/bin:/usr/local/bin
SHELL=/usr/local/bin/zsh
TERM=xterm
USER=apps
Could not find rake-13.0.1 in any of the sources
Could not find rake-13.0.1 in any of the sources
Run `bundle install` to install missing gems.
Run `bundle install` to install missing gems.
doing _rc_rm_runfile
(failed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment