pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

declare app dependencies inside ecosystem

Open mario-mui opened this issue 8 years ago • 7 comments

Supporting information

I has json file like this:

"apps": [

  {
       "name": "app1"
       "scripe" : "app.js"
       "cwd": "/app1/"
       "wait_ready": true
  },

 {
       "name": "app2"
       "scripe" : "app.js"
       "cwd": "/app2/"
        "wait_ready": true
  }

]

Can pm2 start /app2/app.js after App name 'app1' status is online?

PM2 version: 2.4.4
Node version: 6.9.4
Linux

mario-mui avatar Apr 12 '17 03:04 mario-mui

We should add a option to be able to declare dependencies between app like docker-compose do.

vmarchaud avatar Apr 12 '17 15:04 vmarchaud

Any update? Thanks.

abawchen avatar Dec 09 '19 04:12 abawchen

This would be a really good idea as this is a common scenario in production. Any update on this?

ParagMeshram avatar Oct 20 '20 12:10 ParagMeshram

Any update on this? I would like to use this feature too.

yoonwaiyan avatar Jan 07 '21 05:01 yoonwaiyan

2022 any update?

gtrabanco avatar Oct 22 '22 13:10 gtrabanco

This would be a good feature to have.

bgfernandes avatar Nov 20 '22 13:11 bgfernandes

No updates? :(

patric0889 avatar Sep 15 '24 14:09 patric0889

This would be useful for having startup parity between k8s, docker, and others. K8s provides "init-containers", and docker compose allows you to declare depends_on - both allow you to do things before your app runs. This includes (but is not limited to):

  • Waiting for databases to be running and accepting connections
  • Running database migrations
  • Provisioning users for both the database and application
  • Ensuring network drives are mounted
  • Starting system-level services (smtp, et al)
  • Anything else required for the app to run with determinism

These tasks are required for the app to run, but are not the concern of application code. Many of these processes need to run with special admin/root privileges and should run separately (sandboxed) from the app. I know we can wrap pm2 in our own scripts to do all of this, but it would be much cleaner to make it declarative inside pm2 configs. This would allow pm2 configs to mirror k8s and docker.

DesignByOnyx avatar Oct 23 '24 21:10 DesignByOnyx