close
The Wayback Machine - https://web.archive.org/web/20190518024454/https://github.com/Unitech/pm2/pull/3789
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start/restart/stop priority feature implementation #3789

Open
wants to merge 10 commits into
base: development
from

Conversation

Projects
None yet
4 participants
@livankrekh
Copy link
Contributor

commented Jul 12, 2018

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #1234, #5678
License MIT
Doc PR https://github.com/pm2-hive/pm2-hive.github.io/pulls

livankrekh added some commits Jul 12, 2018

@livankrekh livankrekh force-pushed the livankrekh:priority branch from c5ebdad to 9c87b2f Aug 3, 2018

@livankrekh livankrekh force-pushed the livankrekh:priority branch from 9c87b2f to 9dbffaf Aug 3, 2018

@vmarchaud

This comment has been minimized.

Copy link
Contributor

commented Aug 17, 2018

Is this PR still alive ? Can you explain a little bit more about what you want to achieve ?

wallet77 added some commits Aug 17, 2018

@livankrekh

This comment has been minimized.

Copy link
Contributor Author

commented Aug 21, 2018

Hi, @vmarchaud
The main idea of this PR and feature: starting and stoping processes by ecosystem order (priority and stop_priority properties)
That realized in the next way:

  1. List of processes (appConf, apps_to_start and others) sorting by this priority (by checkPriority function). If processes have same priority - these processes collecting in array, that included in process list (for example: process1.priority: 2, process2.priority: 1, process3.priority: 20, process4.priority: 2. Result will be: [process2, [process1, process4], process3] )
  1. That processes list will be handled by async.eachSeries (all processes will be executed
    consistently). If async.eachSeries get a array of processes (when processes have same priority), in this case each process of array will be executed parallel
  2. eachSeries starts next process, if previous process called callback. Callback calling, when child process send signal 'pm2:started' or 'ready', it means that process is online. It works for process or cluster. That realized in God.js realizeQueue function (for start command) and in ActionMethods.js (for restart command). Clustered process have status online, when every cluster send signal 'ready' or 'pm2:started'

Start/restart/stop priority behavior in pm2:

  1. Start/restart priority works in case, when at least one process has 'priority' property in ecosystem

  2. Stop priority works in case, when at least one process has 'stop_priority' or 'priority' property

  3. If two or more processes has same priority, they starting in the same time by async

  4. In case, when at least on process has not valid priority (number more than count of processes or hasn't priority) processes starting/stoping by next order: 1) processes has valid priority, 2) processes has not valid priority, 3) processes without priority
    For example, Process_1.priority: 35, Process_2.priority: null, Process_3.priority: 1; Starting prio: Process_3 --------> Process_1 -------> Process_2

  5. Process and cluster is online, when pm2 got 'pm2:started' or 'ready' message from this process

  6. If processes started by one priority case and after that priority has been changed, restart command will restart processes by new priority order

@Unitech Unitech force-pushed the Unitech:development branch from 79699fb to 020ca74 Sep 7, 2018

@Unitech Unitech force-pushed the Unitech:development branch from 4dc68d4 to b4708e7 Sep 21, 2018

@Unitech Unitech force-pushed the Unitech:development branch 2 times, most recently from 7641d49 to 495c77f Dec 18, 2018

@msupra

This comment has been minimized.

Copy link

commented Feb 11, 2019

Hi

Have this been implemented yet, as I have a use case for it?

Regards
Morne

@Unitech Unitech force-pushed the Unitech:development branch 3 times, most recently from ca13ded to 741144e Mar 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.