Skip to content

Conversation

@dreusel
Copy link

@dreusel dreusel commented Nov 1, 2023

This introduces the option to configure a post-start-hook for apps. The hook should be implemented in the form of a js file where the main export is the function taking an info object and callback as its parameters:

module.exports = function hook(info, cb) {
  cb(null);
};

This function will be invoked after the app has been (re)started. The info object contains useful things for knowing about / interacting with the newly running app instance:

  • {string} info.pid The apps PID
  • {Stream} info.stdin The apps STDIN stream
  • {Stream} info.stdout The apps STDOUT stream
  • {Stream} info.stderr The apps STDERR stream
  • {object} pm2_env The apps environment

The hook can be enabled by adding a post_start_hook field to the app configuration blob, for example:

- name: app
  script: app.js
  post_start_hook: post-start-hook.js
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #5705
License MIT
Doc PR pm2-hive/pm2-hive.github.io#250

@CLAassistant
Copy link

CLAassistant commented Nov 1, 2023

CLA assistant check
All committers have signed the CLA.

@dreusel dreusel force-pushed the feat/post-start-hook branch from 19c2919 to 2f1b057 Compare February 22, 2024 17:36
@dreusel dreusel force-pushed the feat/post-start-hook branch from e8d6c25 to 4d24960 Compare June 3, 2025 10:13
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.

2 participants