feat: built in pm2
This commit is contained in:
15
test/__mocks__/deploy-service/ecosystem.config.js
Normal file
15
test/__mocks__/deploy-service/ecosystem.config.js
Normal file
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'app',
|
||||
script: __dirname + '/index.js',
|
||||
watch: false,
|
||||
ignore_watch: ['node_modules'],
|
||||
log_date_format: 'MM-DD HH:mm:ss.SSS Z',
|
||||
env: {},
|
||||
max_restarts: 5,
|
||||
kill_timeout: 10_000,
|
||||
wait_ready: true,
|
||||
},
|
||||
],
|
||||
};
|
23
test/__mocks__/deploy-service/index.js
Normal file
23
test/__mocks__/deploy-service/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { createServer } from 'http';
|
||||
|
||||
var app = createServer(function (req, res) {
|
||||
res.writeHead(200);
|
||||
setTimeout(() => {
|
||||
res.end('hey');
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
var listener = app.listen(0, function () {
|
||||
console.log('Listening on port ' + listener.address().port);
|
||||
setTimeout(() => {
|
||||
// Here we send the ready signal to PM2
|
||||
process.send('ready');
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
process.on('SIGINT', function () {
|
||||
listener.close();
|
||||
setTimeout(() => {
|
||||
process.exit(0);
|
||||
}, 2000);
|
||||
});
|
10
test/__mocks__/deploy-service/package.json
Normal file
10
test/__mocks__/deploy-service/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "deploy-service",
|
||||
"version": "1.0.0",
|
||||
"description": "For Test",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {},
|
||||
"author": "Ivan Li",
|
||||
"license": "ISC"
|
||||
}
|
16
test/__mocks__/deploy-service/test.js
Normal file
16
test/__mocks__/deploy-service/test.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { createServer } from 'http';
|
||||
|
||||
var app = createServer(function (req, res) {
|
||||
res.writeHead(200);
|
||||
setTimeout(() => {
|
||||
res.end('pm2');
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
var listener = app.listen(33333, function () {
|
||||
console.log('Listening on port ' + listener.address().port);
|
||||
setTimeout(() => {
|
||||
// Here we send the ready signal to PM2
|
||||
process.send('ready');
|
||||
}, 5000);
|
||||
});
|
Reference in New Issue
Block a user