feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
14
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/http-server/README.md
generated
vendored
Normal file
14
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/http-server/README.md
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
# Basic HTTP Server and Cluster mode
|
||||
|
||||
In this boilerplate it will start an http server in cluster mode.
|
||||
|
||||
You can check the content of the ecosystem.config.js on how to start mutliple instances of the same HTTP application in order to get the most from your working system.
|
||||
|
||||
## Via CLI
|
||||
|
||||
Via CLI you can start any HTTP/TCP application in cluster mode with:
|
||||
|
||||
```bash
|
||||
$ pm2 start api.js -i max
|
||||
```
|
||||
9
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/http-server/api.js
generated
vendored
Normal file
9
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/http-server/api.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
var http = require('http');
|
||||
|
||||
var server = http.createServer(function(req, res) {
|
||||
res.writeHead(200);
|
||||
res.end('hey');
|
||||
}).listen(process.env.PORT || 8000, function() {
|
||||
console.log('App listening on port %d', server.address().port);
|
||||
});
|
||||
14
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/http-server/ecosystem.config.js
generated
vendored
Normal file
14
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/http-server/ecosystem.config.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
apps : [{
|
||||
name: 'API',
|
||||
script: 'api.js',
|
||||
instances: 4,
|
||||
max_memory_restart: '1G',
|
||||
env: {
|
||||
NODE_ENV: 'development'
|
||||
},
|
||||
env_production: {
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
}]
|
||||
};
|
||||
11
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/http-server/package.json
generated
vendored
Normal file
11
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/http-server/package.json
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "simple-http-server",
|
||||
"version": "1.0.0",
|
||||
"description": "Simple HTTP server that can be used in cluster mode",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
45
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md
generated
vendored
Normal file
45
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
# pm2 custom metrics boilerplate
|
||||
|
||||
In this boilerplate you will discover a working example of custom metrics feature.
|
||||
|
||||
Metrics covered are:
|
||||
- io.metric
|
||||
- io.counter
|
||||
- io.meter
|
||||
- io.histogram
|
||||
|
||||
## What is Custom Metrics?
|
||||
|
||||
Custom metrics is a powerfull way to get more visibility from a running application. It will allow you to monitor in realtime the current value of variables, know the number of actions being processed, measure latency and much more.
|
||||
|
||||
Once you have plugged in some custom metrics you will be able to monitor their value in realtime with
|
||||
|
||||
`pm2 monit`
|
||||
|
||||
Or
|
||||
|
||||
`pm2 describe`
|
||||
|
||||
Or on the PM2+ Web interface
|
||||
|
||||
`pm2 open`
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io')
|
||||
|
||||
const currentReq = io.counter({
|
||||
name: 'CM: Current Processing',
|
||||
type: 'counter'
|
||||
})
|
||||
|
||||
setInterval(() => {
|
||||
currentReq.inc()
|
||||
}, 1000)
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
https://doc.pm2.io/en/plus/guide/custom-metrics/
|
||||
66
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js
generated
vendored
Normal file
66
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
const io = require('@pm2/io')
|
||||
|
||||
// Straight Metric
|
||||
var user_count = 10
|
||||
|
||||
const users = io.metric({
|
||||
name: 'CM: Realtime user',
|
||||
value: () => {
|
||||
return user_count
|
||||
}
|
||||
})
|
||||
|
||||
// or users.set(user_count)
|
||||
|
||||
// Counter (.inc() .dec())
|
||||
const currentReq = io.counter({
|
||||
name: 'CM: Current Processing',
|
||||
type: 'counter'
|
||||
})
|
||||
|
||||
setInterval(() => {
|
||||
currentReq.inc()
|
||||
}, 1000)
|
||||
|
||||
// Meter
|
||||
const reqsec = io.meter({
|
||||
name: 'CM: req/sec'
|
||||
})
|
||||
|
||||
setInterval(() => {
|
||||
reqsec.mark()
|
||||
}, 100)
|
||||
|
||||
|
||||
// Histogram
|
||||
const latency = io.histogram({
|
||||
name: 'CM: latency'
|
||||
});
|
||||
|
||||
var latencyValue = 0;
|
||||
|
||||
setInterval(() => {
|
||||
latencyValue = Math.round(Math.random() * 100);
|
||||
latency.update(latencyValue);
|
||||
}, 100)
|
||||
|
||||
|
||||
////////////////////
|
||||
// Custom Actions //
|
||||
////////////////////
|
||||
|
||||
io.action('add user', (done) => {
|
||||
user_count++
|
||||
done({success:true})
|
||||
})
|
||||
|
||||
io.action('remove user', (done) => {
|
||||
user_count++
|
||||
done({success:true})
|
||||
})
|
||||
|
||||
io.action('with params', (arg, done) => {
|
||||
console.log(arg)
|
||||
done({success:arg})
|
||||
})
|
||||
12
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/ecosystem.config.js
generated
vendored
Normal file
12
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/ecosystem.config.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
apps : [{
|
||||
name: 'Custom Metrics',
|
||||
script: 'custom-metrics.js',
|
||||
env: {
|
||||
NODE_ENV: 'development'
|
||||
},
|
||||
env_production: {
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
}]
|
||||
};
|
||||
11
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/package.json
generated
vendored
Normal file
11
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/package.json
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "pm2-plus-custom-metrics",
|
||||
"version": "1.0.0",
|
||||
"description": "Example that shows how to use pm2+ custom metrics",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
4
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/python-app/README.md
generated
vendored
Normal file
4
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/python-app/README.md
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
# Managing a Python Application
|
||||
|
||||
On this boilerlate you will see how you can start a Python application with PM2.
|
||||
7
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/python-app/echo.py
generated
vendored
Normal file
7
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/python-app/echo.py
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
import time
|
||||
|
||||
while 1:
|
||||
print("Start : %s" % time.ctime())
|
||||
print("second line")
|
||||
time.sleep(1)
|
||||
12
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/python-app/ecosystem.config.js
generated
vendored
Normal file
12
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/python-app/ecosystem.config.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
apps : [{
|
||||
name: 'API',
|
||||
script: 'echo.py',
|
||||
env: {
|
||||
NODE_ENV: 'development'
|
||||
},
|
||||
env_production: {
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
}]
|
||||
};
|
||||
11
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/python-app/package.json
generated
vendored
Normal file
11
api.hyungi.net/node_modules/pm2/lib/templates/sample-apps/python-app/package.json
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "python-app",
|
||||
"version": "1.0.0",
|
||||
"description": "Example on how to manage a Python application with PM2",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
Reference in New Issue
Block a user