Skip to content

FreeBSD Startup Support #3324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2017
Merged

FreeBSD Startup Support #3324

merged 1 commit into from
Dec 4, 2017

Conversation

720720
Copy link
Contributor

@720720 720720 commented Dec 2, 2017

Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #3287
License MIT

Startup.js

function detectInitSystem() {
  var hash_map = {
    'systemctl'  : 'systemd',
    'update-rc.d': 'upstart',
    'chkconfig'  : 'systemv',
    'rc-update'  : 'openrc',
    'launchctl'  : 'launchd',
    'sysrc'      : 'rcd'
  };

we can use sysrc to detect FreeBSD > 9.2

service_name = (opts.serviceName || 'pm2_' + user);

rcvar may not contain a -

destination = '/usr/local/etc/rc.d/' + service_name;

port scripts should go to /usr/local/etc/rc.d/

.replace(/%HOME_PATH%/g, opts.hp ? path.resolve(opts.hp, '.pm2') : cst.PM2_ROOT_PATH);
.replace(/%HOME_PATH%/g, opts.hp ? path.resolve(opts.hp) : cst.PM2_ROOT_PATH)

env PM2_HOME=/srv/www/pm2 pm2 startup -u www
pm2 startup -u www --hp /srv/www/pm2

currently it is impossible to create --hp paths without a .pm2 directory
with path.resolve(opts.hp) PM2_HOME and --hp behave the same way

.replace(/%SERVICE_NAME%/g, service_name);

fb8fbe1 allows custom service names for startup scripts but no script actually uses the service name

rcd.tpl

name="%SERVICE_NAME%"
rcvar="%SERVICE_NAME%_enable"

allows custom service names and multiple startup scripts for the same user

pm2()
{
  env PATH="$PATH:%NODE_PATH%" PM2_HOME="%HOME_PATH%" su -m "%USER%" -c "%PM2_PATH% $*"
}

allows to run PM2 even for system accounts without home directory in any user writable PM2_HOME

@CLAassistant
Copy link

CLAassistant commented Dec 2, 2017

CLA assistant check
All committers have signed the CLA.

@Unitech Unitech merged commit 5cf5f08 into Unitech:development Dec 4, 2017
@Unitech
Copy link
Owner

Unitech commented Dec 4, 2017

awesome, thanks

inerc pushed a commit to inerc/pm2 that referenced this pull request Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants