mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
增加public服务,查询panel日志
This commit is contained in:
@@ -37,6 +37,7 @@ if (envFound.error) {
|
||||
export default {
|
||||
port: parseInt(process.env.BACK_PORT as string, 10),
|
||||
cronPort: parseInt(process.env.CRON_PORT as string, 10),
|
||||
publicPort: parseInt(process.env.PUBLIC_PORT as string, 10),
|
||||
secret: process.env.SECRET || createRandomString(16, 32),
|
||||
logs: {
|
||||
level: process.env.LOG_LEVEL || 'silly',
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import express from 'express';
|
||||
import { exec } from 'child_process';
|
||||
import Logger from './loaders/logger';
|
||||
import config from './config';
|
||||
|
||||
const app = express();
|
||||
|
||||
const run = async () => {
|
||||
app.get('/api/public/panel/log', (req, res) => {
|
||||
exec('pm2 logs panel --lines 500', (err, stdout, stderr) => {
|
||||
if (err || stderr) {
|
||||
return res.send({ code: 400, data: err || stderr });
|
||||
}
|
||||
return res.send({ code: 200, data: stdout });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
app
|
||||
.listen(config.publicPort, async () => {
|
||||
await require('./loaders/sentry').default({ expressApp: app });
|
||||
await require('./loaders/db').default();
|
||||
|
||||
await run();
|
||||
Logger.info(`
|
||||
################################################
|
||||
🛡️ Public listening on port: ${config.publicPort} 🛡️
|
||||
################################################
|
||||
`);
|
||||
})
|
||||
.on('error', (err) => {
|
||||
Logger.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user