chore: add ecosystem.config

This commit is contained in:
scarqin 2023-03-15 11:45:56 +08:00
parent 361bc9af8a
commit d67d7395a3
8 changed files with 124 additions and 100 deletions

View File

@ -0,0 +1,13 @@
module.exports = {
apps: [
{
name: 'extension-runtime',
script: 'main.js',
watch: '.'
}
],
deploy: {
production: {}
}
};

View File

@ -6,8 +6,8 @@
"scripts": {
"prepare": "node tools/install.cjs",
"dev": "nodemon main",
"start": "pm2 start main.js",
"stop": "pm2 stop main.js",
"start": "pm2 start ecosystem.config.cjs",
"stop": "pm2 stop ecosystem.config.cjs",
"log": "pm2 logs"
},
"type": "module",

View File

@ -0,0 +1,17 @@
module.exports = {
apps: [
{
name: 'http-server',
script: 'server/main.js',
watch: '.'
},
{
name: 'websocket-server',
script: 'server/socketio.js',
watch: '.'
}
],
deploy: {
production: {}
}
};

View File

@ -5,12 +5,9 @@
"main": "./server/main.js",
"scripts": {
"dev": "node ./server/main.js",
"start": "pm2-runtime start ./server/main.js",
"start:io": "pm2-runtime start ./server/socketio.js",
"start:all": "yarn start && yarn start:io",
"start:all:pm2": "pm2 start ./server/main.js",
"start": "pm2 start ecosystem.config.js",
"watch": "pm2 list",
"stop": "pm2 stop all",
"stop": "pm2 stop ecosystem.config.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Postcat",

View File

@ -8,7 +8,6 @@ const _LibsCommon = require('../request/libs/common.js');
const koaBody = require('koa-body');
const Koa = require('koa');
const cors = require('@koa/cors');
const socketio = require('./socketio.js');
const app = new Koa();
const port = process.env.TEST_SERVER_PORT || 4201;
@ -46,6 +45,5 @@ app.use(async (ctx, next) => {
next();
});
socketio();
app.listen(port);
console.log(`Server is running at port ${port} ...`);

View File

@ -8,7 +8,6 @@ process.on('uncaughtException', err => {
const _post = process.env.EOAPI_WEBSOCKET_PORT || 13928;
const socket = (port = _post) => {
const io = new IO.Server(port, {
transports: ['websocket']
});
@ -102,6 +101,5 @@ const socket = (port = _post) => {
}
});
});
};
module.exports = socket;

View File

@ -17,7 +17,7 @@ import path from 'node:path';
const extServerMap = new Map<string, SidebarView>();
// * npm pkg name
const defaultExtension = [{ name: 'postcat-export-openapi' }, { name: 'postcat-import-openapi' }];
const defaultExtension = [{ name: 'postcat-export-openapi' }, { name: 'postcat-import-openapi' }, { name: 'postcat-basic-auth' }];
const isExists = async filePath =>
await promises
.access(filePath)

View File

@ -32,7 +32,8 @@
"scripts/build.js",
"test/e2e/test.ts",
"test/e2e/test.ts",
"src/node/extensions-manage/extension-manage.js"
"src/node/extensions-manage/extension-manage.js",
"src/node/test-server/ecosystem.config.js"
],
"exclude": ["node_modules", "**/*.spec.ts", "**/browser/**/*.js", "**/browser/**/*.ts", "out"],
"angularCompilerOptions": {