diff --git a/README.md b/README.md index 445b4e9c6..b1374b7f0 100644 --- a/README.md +++ b/README.md @@ -228,14 +228,14 @@ $ pm2 reloadLogs # Reload all logs PM2 can generates and configure a startup script to keep PM2 and your processes alive at every server restart. -Supports init systems like: **systemd** (Ubuntu 16, CentOS, Arch), **upstart** (Ubuntu 14/12), **launchd** (MacOSx, Darwin), **rc.d** (FreeBSD). +Supports init systems like: **systemd** (Ubuntu 16, CentOS, Arch), **upstart** (Ubuntu 14/12), **launchd** (MacOSx, Darwin), **rc.d** (FreeBSD, OpenBSD). ```bash # Auto detect init system + generate and setup PM2 boot at server startup $ pm2 startup # Manually specify the startup system -# Can be: systemd, upstart, launchd, rcd +# Can be: systemd, upstart, launchd, rcd, rcd-openbsd $ pm2 startup [platform] # Disable and remove PM2 boot at server startup diff --git a/lib/API/Startup.js b/lib/API/Startup.js index d35cd05cf..8916e0377 100644 --- a/lib/API/Startup.js +++ b/lib/API/Startup.js @@ -41,7 +41,8 @@ module.exports = function(CLI) { 'chkconfig' : 'systemv', 'rc-update' : 'openrc', 'launchctl' : 'launchd', - 'sysrc' : 'rcd' + 'sysrc' : 'rcd', + 'rcctl' : 'rcd-openbsd', }; var init_systems = Object.keys(hash_map); @@ -147,6 +148,16 @@ module.exports = function(CLI) { 'sysrc -x ' + service_name + '_enable', 'rm /usr/local/etc/rc.d/' + service_name ]; + break; + case 'rcd-openbsd': + service_name = (opts.serviceName || 'pm2_' + user); + var destination = path.join('/etc/rc.d', service_name); + commands = [ + 'rcctl stop ' + service_name, + 'rcctl disable ' + service_name, + 'rm ' + destination + ]; + break; }; require('shelljs').exec(commands.join('&& '), function(code, stdout, stderr) { @@ -270,6 +281,17 @@ module.exports = function(CLI) { 'sysrc ' + service_name + '_enable=YES' ]; break; + case 'openbsd': + case 'rcd-openbsd': + template = getTemplate('rcd-openbsd'); + service_name = (opts.serviceName || 'pm2_' + user); + destination = path.join('/etc/rc.d/', service_name); + commands = [ + 'chmod 755 ' + destination, + 'rcctl enable ' + service_name, + 'rcctl start ' + service_name + ]; + break; case 'openrc': template = getTemplate('openrc'); service_name = openrc_service_name; diff --git a/lib/templates/init-scripts/rcd-openbsd.tpl b/lib/templates/init-scripts/rcd-openbsd.tpl new file mode 100644 index 000000000..590a995e1 --- /dev/null +++ b/lib/templates/init-scripts/rcd-openbsd.tpl @@ -0,0 +1,41 @@ +#!/bin/sh +# +# from /usr/ports/infrastructure/templates/rc.template + +daemon="/usr/local/bin/pm2" +#daemon_flags= +#daemon_rtable=0 +#daemon_timeout="30" +daemon_user="%USER%" + +. /etc/rc.d/rc.subr + +pexp="node: PM2.*God Daemon.*" +#rc_bg= # (undefined) +#rc_reload= # (undefined) +#rc_usercheck=YES + +#rc_pre() { +#} + +rc_start() { + ${rcexec} "${daemon} ${daemon_flags} resurrect" +} + +#rc_check() { +# pgrep -T "${daemon_rtable}" -q -xf "${pexp}" +#} + +rc_reload() { + ${rcexec} "${daemon} reload all" + #pkill -HUP -T "${daemon_rtable}" -xf "${pexp}" +} + +#rc_stop() { +# pkill -T "${daemon_rtable}" -xf "${pexp}" +#} + +#rc_post() { +#} + +rc_cmd $1