Skip to content

Instantly share code, notes, and snippets.

@No9
Last active August 27, 2018 15:46
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 No9/44a96dbbee9e47dc8104c5afe53be56d to your computer and use it in GitHub Desktop.
Save No9/44a96dbbee9e47dc8104c5afe53be56d to your computer and use it in GitHub Desktop.
A set of files to act as a template for running a PM2 job in a jail
#!/bin/sh
# PROVIDE: blog
# Save this into /usr/local/etc/rc.d/blog
# Make sure it's executable and validate with
# /usr/local/etc/rc.d/blog rcvar
# This will allow you to stop and start the service with:
# service blog restart
. /etc/rc.subr
name="blog"
rcvar=blog_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"
load_rc_config $name
PATH=$PATH:/usr/local/bin
export PM2_HOME=/root/.pm2
blog_start()
{
if checkyesno ${rcvar}; then
/usr/local/bin/pm2 start path/to/index.js --name "blog"
fi
}
blog_stop()
{
pm2 stop blog
}
run_rc_command "$1"
# Save this as /usr/local/etc/rc.conf
blog_enable="YES"
#!/bin/sh
# make sure this file executable
/usr/local/etc/rc.d/blog start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment