{"id":19177743,"url":"https://github.com/jessety/pm2-installer","last_synced_at":"2025-04-04T19:11:17.378Z","repository":{"id":40451634,"uuid":"202409806","full_name":"jessety/pm2-installer","owner":"jessety","description":"Install PM2 offline as a service on Windows or Linux. Mostly designed for Windows.","archived":false,"fork":false,"pushed_at":"2024-01-23T22:05:42.000Z","size":273,"stargazers_count":515,"open_issues_count":46,"forks_count":52,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-03-28T18:15:19.661Z","etag":null,"topics":["installer","offline","offline-capable","pm2","pm2-installer","pm2-offline","pm2-offline-installer","pm2-service","pm2-service-windows","pm2-setup","pm2-windows","pm2-windows-installer","pm2-windows-service","pm2-windows-startup","powershell","service","windows","windows-service"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jessety.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jessety","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-08-14T19:03:53.000Z","updated_at":"2025-03-20T01:33:41.000Z","dependencies_parsed_at":"2024-11-09T10:36:15.110Z","dependency_job_id":"3347f334-4a62-4301-bf03-b29cb4d51424","html_url":"https://github.com/jessety/pm2-installer","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fpm2-installer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fpm2-installer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fpm2-installer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fpm2-installer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jessety","download_url":"https://codeload.github.com/jessety/pm2-installer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234921,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["installer","offline","offline-capable","pm2","pm2-installer","pm2-offline","pm2-offline-installer","pm2-service","pm2-service-windows","pm2-setup","pm2-windows","pm2-windows-installer","pm2-windows-service","pm2-windows-startup","powershell","service","windows","windows-service"],"created_at":"2024-11-09T10:34:56.365Z","updated_at":"2025-04-04T19:11:17.353Z","avatar_url":"https://github.com/jessety.png","language":"PowerShell","funding_links":["https://github.com/sponsors/jessety"],"categories":[],"sub_categories":[],"readme":"# pm2-installer\n\n`pm2-installer` is designed to automate installation of pm2 as a service, particularly on Windows, even in environments without Internet access.\n\n### Windows Support\n\nUnfortunately, PM2 has no built-in startup support for Windows. PM2's [documentation](https://pm2.keymetrics.io/docs/usage/startup/#windows-consideration) recommends using either `pm2-windows-service` or `pm2-windows-startup`. However, both of these projects have some real drawbacks.\n\n`pm2-windows-startup` adds an entry to the registry to start pm2 after user login. Because it does not create a service, PM2 will not be running until a user has logged into the user interface, and will halt when they log out. It has not been updated since 2015.\n\n`pm2-windows-service` uses `node-windows` to create a service that runs pm2. This is a much better approach, but it hasn't been maintained since 2018, has outdated dependencies that cause crashes on setup, and currently fails to run properly on Node 14. It also runs the service as the the `Local System` user instead of `Local Service`.\n\nThis project creates its own Windows Service using the current version of `node-windows` and a series of PowerShell scripts inspired by [this excellent gist](https://gist.github.com/mauron85/e55b3b9d722f91366c50fddf2fca07a4) by [@maxfierke](https://github.com/maxfierke) \u0026 [@mauron85](https://github.com/mauron85).\n\nWhen running on Windows, `pm2-installer` will:\n\n- Configure `npm` to keep its global files in `C:\\ProgramData\\npm`, instead of keeping them in the current user's `%APPDATA%`\n- Install `pm2` globally, using an offline cache if necessary\n- Create the `C:\\ProgramData\\pm2` directory and set the `PM2_HOME` environmental variable at the machine level\n- Set permissions both the new `npm` and `pm2` folders so that the Local Service user may access them\n- Leverage `node-windows` to install a new Windows service\n- Use PowerShell to configure the service to run as the Local Service user (due to [node-windows#89](https://github.com/coreybutler/node-windows/issues/89))\n- Confirm the service is running properly\n- Install the `pm2-logrotate` module so that log files don't fill up the disk\n\nAfter that, `pm2` will be running in the background the `Local Service` user. It will persist across reboots and continue running regardless of which user is logged in. To add your app, run `pm2 start app.js` from an admin command line interface. Make sure to run `pm2 save` to serialize the process list.\n\n## Install\n\nDownload the latest version [here](https://github.com/jessety/pm2-installer/archive/main.zip).\n\nCopy the entire `pm2-installer` directory onto the target machine, then run:\n\n```bash\nnpm run setup\n```\n\nOn Windows, the `setup` script assumes you have already configured `npm` to use `prefix` and `cache` directories in a location accessible to the `Local Service` user. If not, it will issue a warning and ask if you're sure you'd like to proceed.\nTo set up `npm` automatically, run `configure` first:\n\n```bash\nnpm run configure\nnpm run setup\n```\n\nThat's it.\n\n\u003e NOTE: Running `npm install` is not necessary, unless you're developing `pm2-installer` itself and want to lint the project.\n\n### Offline Install\n\n`pm2-installer` is also designed to function without an internet connection. It does this by creating a cache on an internet-connected build machine, then installing from that cache when run on the offline deployment machine.\n\nOn an internet-connected build machine running the same OS as the deployment target, run the following:\n\n```bash\nnpm run bundle\n```\n\nThis will populate the cache in the project's directory with the resources required to install offline. Transfer the entire `pm2-installer` directory onto the deployment target, then run:\n\n```bash\nnpm run setup\n```\n\n`pm2-installer` will check if it can contact the npm registry and install online if possible, or use the offline cache if not.\n\n### Windows Install\n\nThere are a couple additional challenges when installing on a fresh Windows machine. The `npm` global directory is not accessible to other users by default, which means the `Local Service` user will not be able to locate the `pm2` executable. Additionally, if the machine's PowerShell execution policy is `Undefined` or `Restricted`, invoking `pm2` in PowerShell will fail- even though the setup script unblocks `pm2.ps1`.\n\n`pm2-installer` includes two additional scripts to automatically fix the above issues. Invoking `npm run configure` will create the `C:\\ProgramData\\npm\\`, and set `npm` to use `prefix` and `cache` locations in that directory. Running `npm run configure-policy` checks the machine's PowerShell execution policy and if it is either `undefined` or `Restricted`, updates it to `RemoteSigned`.\n\nOpen an elevated terminal (e.g. right click and select \"Run as Admin\") and run the following commands first:\n\n```pwsh\nnpm run configure\nnpm run configure-policy\n```\n\nThen, run `npm run setup` to install the pm2 service.\n\n#### Additional context for Windows installations\n\n- The `pm2` service runs as the `Local Service` user. To interact with `pm2`, you need to use an elevated terminal (e.g. right click and select \"Run as Admin\") before running any commands that interface with the service, e.g. `pm2 list`.\n- If you update node and npm, make sure to either manually re-configure your npm \u0026 node installations or run `npm run configure` again.\n- This project does not currently support nvm for windows. It requires a standard node installation.\n\n## Removal\n\nTo remove the pm2 service, run:\n\n```bash\nnpm run remove\n```\n\nThis will remove the service and completely uninstall pm2.\n\nIf you used the `configure` script on Windows to configure `npm`, you can revert those settings by running:\n\n```bash\nnpm run deconfigure\n```\n\n## License\n\nMIT © Jesse Youngblood\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjessety%2Fpm2-installer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjessety%2Fpm2-installer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjessety%2Fpm2-installer/lists"}