{"record":{"id":"1a908a1c96245633","repo":"Unitech/pm2","slug":"unknown-platform-init-system-name","errorCode":null,"errorMessage":"Unknown platform / init system name","messagePattern":"Unknown platform / init system name","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/API/Startup.js","lineNumber":331,"sourceCode":"      destination = '/etc/init.d/' + service_name;\n      commands = [\n        'chmod +x ' + destination,\n        'rc-update add ' + service_name + ' default'\n      ];\n      break;\n    case 'smf':\n    case 'sunos':\n    case 'solaris':\n      template = getTemplate('smf');\n      service_name = (opts.serviceName || 'pm2_' + user);\n      destination = path.join(tmpPath(), service_name + '.xml');\n      commands = [\n        'svccfg import ' + destination,\n        'svcadm enable ' + service_name\n      ];\n      break;\n    default:\n      throw new Error('Unknown platform / init system name');\n    }\n\n    /**\n     * 4# Replace template variable value\n     */\n    var envPath\n\n    if (cst.HAS_NODE_EMBEDDED == true)\n      envPath = util.format('%s:%s', process.env.PATH || '', path.dirname(process.execPath))\n    else if (new RegExp(path.dirname(process.execPath)).test(process.env.PATH))\n      envPath = process.env.PATH\n    else\n      envPath = util.format('%s:%s', process.env.PATH || '', path.dirname(process.execPath))\n\n    let pm2_bin_path = require.main.filename\n\n    if (pm2_bin_path.includes('/lib/binaries/CLI.js') === true) {\n      pm2_bin_path = pm2_bin_path.replace('/lib/binaries/CLI.js', '/bin/pm2')","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/Unitech/pm2/blob/31adee8048dbbc1ee36a7df7cdbcaca2559708df/lib/API/Startup.js#L313-L349","documentation":"After platform is resolved, PM2 switches over the recognized init systems (systemd, upstart, launchd, systemv, openrc, rcd, rcd-openbsd, smf) to pick the matching template and commands. Reaching the default case means a platform string was supplied that is not in that set.","triggerScenarios":"Passing an invalid or misspelled platform to `pm2 startup <platform>` — e.g. `pm2 startup systemctl` (the tool name rather than the init name) or `pm2 startup systemds`.","commonSituations":"Confusing the init-system name (systemd) with its tool (systemctl); typos; passing a made-up platform string.","solutions":["Use one of the supported names: systemd, upstart, launchd, systemv, openrc, rcd, rcd-openbsd, smf.","Run `pm2 startup` with no argument and let PM2 auto-detect.","Double-check spelling against the supported list."],"exampleFix":"// before\npm2 startup systemctl\n// after\npm2 startup systemd","handlingStrategy":"validation","validationCode":"const VALID = ['systemd','upstart','launchd','systemv','openrc','rcd','rcd-openbsd','smf'];\nif (!VALID.includes(platform)) {\n  throw new Error(`Unsupported platform '${platform}'; use one of: ${VALID.join(', ')}`);\n}","typeGuard":"const isKnownPlatform = (p) =>\n  ['systemd','upstart','launchd','systemv','openrc','rcd','rcd-openbsd','smf'].includes(p);","tryCatchPattern":null,"preventionTips":["Whitelist platform values against the documented set before passing to startup.","Remember the platform is the init-system name (systemd), not the tool (systemctl)."],"tags":["startup","init-system","invalid-argument"],"backgroundTag":null,"analyzedSha":"31adee8048dbbc1ee36a7df7cdbcaca2559708df","analyzedAt":"2026-08-13T03:49:51.765Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}