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

Cpu limit #3912

Closed
wants to merge 2 commits into from
Closed

Cpu limit #3912

wants to merge 2 commits into from

Conversation

deanrather
Copy link
Contributor

Adds support for an optional cpu_limit option on applications defined in the environment.config.js file.

eg:

// environment.config.json
module.exports = {
  apps: [{
      script: './heavy-service.sh',
      args: ['--port=1111', '--name=service1'],
      cpu_limit: 1
    },
    {
      script: './heavy-service.sh',
      args: ['--port=2222', '--name=service2'],
      cpu_limit: 1
    },
    {
      script: './heavy-service.sh',
      args: ['--port=3333', '--name=service3'],
      cpu_limit: 1
    },
    {
      script: './heavy-service.sh',
      args: ['--port=4444', '--name=service4'],
      cpu_limit: 10
    }, {
      script: './heavy-service.sh',
      args: ['--port=5555', '--name=service5'],
      cpu_limit: 10
    }
  ]
};
#!/bin/bash
# heavy-service.sh

example_arg1=$1
example_arg2=$2

# this will use up all available CPU

while true; do
  echo "heavy-service running with example_arg1: $example_arg1, example_arg2: $example_arg2"
  # sleep 0.000001
done
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR https://github.com/pm2-hive/pm2-hive.github.io/pulls

@CLAassistant
Copy link

CLAassistant commented Sep 14, 2018

CLA assistant check
All committers have signed the CLA.

@Unitech
Copy link
Owner

Unitech commented Oct 5, 2018

good PR idea
We've noticed that since Node 10.10 there is os.{get,set}Priority nodejs/node#22407
It would be better to leverage this API instead

@Unitech Unitech force-pushed the development branch 2 times, most recently from 7641d49 to 495c77f Compare December 18, 2018 17:20
@Unitech Unitech force-pushed the development branch 3 times, most recently from ca13ded to 741144e Compare March 8, 2019 09:32
@Unitech Unitech deleted the branch Unitech:development February 17, 2022 09:13
@Unitech Unitech closed this Feb 17, 2022
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.

3 participants