{"id":44624957,"url":"https://github.com/desaroger/pm2-hooks","last_synced_at":"2026-02-14T15:07:37.128Z","repository":{"id":57116187,"uuid":"82723848","full_name":"desaroger/pm2-hooks","owner":"desaroger","description":"Webhook server for pm2","archived":false,"fork":false,"pushed_at":"2019-07-12T19:59:33.000Z","size":122,"stargazers_count":33,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-17T17:00:16.778Z","etag":null,"topics":["pm2","webhooks"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/desaroger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-21T20:28:01.000Z","updated_at":"2025-07-06T15:01:09.000Z","dependencies_parsed_at":"2022-08-22T22:10:25.378Z","dependency_job_id":null,"html_url":"https://github.com/desaroger/pm2-hooks","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/desaroger/pm2-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desaroger%2Fpm2-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desaroger%2Fpm2-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desaroger%2Fpm2-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desaroger%2Fpm2-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/desaroger","download_url":"https://codeload.github.com/desaroger/pm2-hooks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desaroger%2Fpm2-hooks/sbom","scorecard":{"id":335934,"data":{"date":"2025-08-11","repo":{"name":"github.com/desaroger/pm2-hooks","commit":"9300f91751663c66007118a71503c7953b4bcb5d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T04:42:56.098Z","repository_id":57116187,"created_at":"2025-08-18T04:42:56.098Z","updated_at":"2025-08-18T04:42:56.098Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29447768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T14:10:32.461Z","status":"ssl_error","status_checked_at":"2026-02-14T14:09:49.945Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["pm2","webhooks"],"created_at":"2026-02-14T15:07:31.891Z","updated_at":"2026-02-14T15:07:37.119Z","avatar_url":"https://github.com/desaroger.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pm2-hooks\n\n[![GitHub version][fury-badge]][fury-url]\n[![Travis-CI][travis-badge]][travis-url]\n[![Codeclimate][codeclimate-badge]][codeclimate-url]\n[![Codeclimate Coverage][codeclimate-cov-badge]][codeclimate-cov-url]\n[![Dependency][david-badge]][david-url]\n[![DevDependency][david-dev-badge]][david-dev-url]\n\nPM2 module to listen webhooks from github, bitbucket, gitlab, jenkins and droneci. When a webhook is received you can run a script, pull your project, restart pm2, etc.\n\nThis project is highly inspired by [vmarchaud/pm2-githook](https://github.com/vmarchaud/pm2-githook).\n\nFeatures ([changelog](/CHANGELOG.md)):\n\n- Runs an http server listening for webhooks\n- Works on any repository system, as for now it does nothing with the payload received. In the near future I will check the branch or the action, the secret, etc.\n- Only runs the command you set\n- Run the command in the cwd defined for the app\n\nWanted features, to be done during Mach/2017:\n\n- Check payload for secret, check common headers on main git repositories (github, bitbucket, gitlab, etc) to know if is a valid call\n\nPossible features, as I need to think about it:\n\n- Auto-restart pm2 app after a successful command run\n- Make an automatic `git pull` on the folder, and make a `prePull` and `postPull` available commands (same approach as [vmarchaud/pm2-githook](https://github.com/vmarchaud/pm2-githook))\n\n# Install\n\nTo install it simply run:\n\n```bash\n$ pm2 install pm2-hooks\n```\n\nWarning: This library currently (2017 feb 26) is in ALPHA state. This means some things:\n\n- You can help me a lot making a comment/issue/PR\n- I will try to publish the last version to npm so you can install it with only `pm2 install pm2-hooks`. If for some reason the version on npm is outdated you always will be capable of run `pm2 install desaroger/pm2-hooks` to be sure to install the last version directly from the repository.\n\n\n# Usage\n\n## Step 1: Prepare the ecosystem file\n\nBy default **pm2-hooks** doesn't do anything. You need to set the key `env_hook` inside the config of a given app, inside the ecosystem file.\n\nIf env_hook isn't defined or is falsy then is disabled.\n\nExample of an ecosystem file:\n\n```js\n{\n\tapps: [\n\t\t{\n\t\t\tname: 'api-1',\n\t\t\tscript: 'server.js'\n\t\t},\n\t\t{\n\t\t\tname: 'api-2',\n\t\t\tscript: 'server.js',\n\t\t\tenv_hook: {\n\t\t\t\tcommand: 'git pull \u0026\u0026 npm i \u0026\u0026 npm test \u0026\u0026 pm2 restart api-2',\n\t\t\t\tcwd: '/home/desaroger'\n\t\t\t}\n\t\t}\n\t]\n}\n```\n\nWhere **api-1** has hook disabled and **api-2** is enabled and when the hook is called, the command is executed.\n\n### Available options:\n\n- **command** *{string}* The line you want to execute. Will be executed with NodeJS `spawn`. (optional, but if not set this is not going to do nothing ¯\\\\_(ツ)_/¯)\n- **cwd** *{string}* The cwd to use when running the command. If not set, the one used on your ecosystem app configuration will be used (if set).\n- **commandOptions** *{object}* The object that we will pass to the NodeJS `spawn`. Defaults to a blank object, and later we add the *cwd*.\n- **type** *{string}* [not implemented yet] The git server you are going to use [github, gitlab, bitbucket, etc].\n\n## Step 2: Install\n\nIf you didn't install before, install it. If you installed it, then you will need to restart it. For that, run `pm2 restart pm2-hooks`.\n\n## Step 3: Try it\n\nNow you have a server on port 9000 by default. You can make a call to `http://localhost:9000/api-2` to see the response.\n\nIf everything went fine, you will see:\n\n```js\n{\n\tstatus: 'success',\n\tmessage: 'Route \"api-2\" was found'\n\tcode: 0\n}\n```\n\nAnd the command had been executed.\n\n## Step 4: See the log\n\nEverything will be logged in the pm2 logs. For see them, run:\n\n```bash\n$ pm2 logs pm2-hooks\n```\n\nAnd for see the entire log:\n\n```bash\n$ cat ~/.pm2/logs/pm2-hooks-out-0.log\n```\n\n# FAQ\n\n## How I can change the port?\n\nYou can set the port (where the default port is 9000) setting it in the config of the pm2 module. For doing that, run:\n\n```bash\n$ pm2 set pm2-hooks:port 3000\n```\n\n## How I can uninstall it?\n\nYou can uninstall this module running:\n\n```bash\n$ pm2 uninstall pm2-hooks\n```\n\n# Another similar projects\n\nThese are some projects I found similar to mine. Please let me know if you know anoher.\n\n- [vmarchaud/pm2-githook](https://github.com/vmarchaud/pm2-githook): From where I was inspired. It works on any repository, pulls the repo when webhook is called and has *preHook* and *postHook* commands available.\n- [oowl/pm2-webhook](https://github.com/oowl/pm2-webhook): Works on any repository. If you want to use the *secret*, then the webhook must contain the *X-Hub-Signature* in order to work (I don't know if every git server contains it).\n\n# Copyright and license\n\nCopyright 2017 Roger Fos Soler\n\nLicensed under the [MIT License](/LICENSE).\n\n\n[npm-badge]: https://img.shields.io/npm/v/pm2-hooks.svg\n[npm-url]: https://www.npmjs.com/package/pm2-hooks\n\n[fury-badge]: https://badge.fury.io/js/pm2-hooks.svg\n[fury-url]: https://www.npmjs.com/package/pm2-hooks\n\n[travis-badge]: https://travis-ci.org/desaroger/pm2-hooks.svg\n[travis-url]: https://travis-ci.org/desaroger/pm2-hooks\n\n[david-badge]: https://david-dm.org/desaroger/pm2-hooks.svg\n[david-url]: https://david-dm.org/desaroger/pm2-hooks\n[david-dev-badge]: https://david-dm.org/desaroger/pm2-hooks/dev-status.svg\n[david-dev-url]: https://david-dm.org/desaroger/pm2-hooks#info=devDependencies\n\n[gemnasium-badge]: https://gemnasium.com/badges/github.com/desaroger/pm2-hooks.svg\n[gemnasium-url]: https://gemnasium.com/github.com/desaroger/pm2-hooks\n\n[codeclimate-badge]: https://codeclimate.com/github/desaroger/pm2-hooks/badges/gpa.svg\n[codeclimate-url]: https://codeclimate.com/github/desaroger/pm2-hooks\n\n[codeclimate-cov-badge]: https://codeclimate.com/github/desaroger/pm2-hooks/badges/coverage.svg?hash=1\n[codeclimate-cov-url]: https://codeclimate.com/github/desaroger/pm2-hooks/coverage\n\n[coverage-badge]: https://codeclimate.com/github/desaroger/pm2-hooks/badges/coverage.svg\n[coverage-url]: https://codeclimate.com/github/desaroger/pm2-hooks/coverage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesaroger%2Fpm2-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesaroger%2Fpm2-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesaroger%2Fpm2-hooks/lists"}