添加监听地址
This commit is contained in:
@@ -7,6 +7,7 @@ const prometheusService = require('./prometheus-service');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
@@ -71,7 +72,7 @@ app.post('/api/setup/init', async (req, res) => {
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
url VARCHAR(500) NOT NULL,
|
||||
description TEXT DEFAULT '',
|
||||
description TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
@@ -86,6 +87,7 @@ MYSQL_USER=${user || 'root'}
|
||||
MYSQL_PASSWORD=${password || ''}
|
||||
MYSQL_DATABASE=${dbName}
|
||||
PORT=${process.env.PORT || 3000}
|
||||
HOST=${process.env.HOST || '0.0.0.0'}
|
||||
REFRESH_INTERVAL=${process.env.REFRESH_INTERVAL || 5000}
|
||||
`;
|
||||
fs.writeFileSync(path.join(__dirname, '..', '.env'), envContent);
|
||||
@@ -355,8 +357,8 @@ app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '..', 'public', 'index.html'));
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
app.listen(PORT, HOST, () => {
|
||||
console.log(`\n 🚀 Data Visualization Display Wall`);
|
||||
console.log(` 📊 Server running at http://localhost:${PORT}`);
|
||||
console.log(` ⚙️ Configure Prometheus sources at http://localhost:${PORT}/settings\n`);
|
||||
console.log(` 📊 Server running at http://${HOST === '0.0.0.0' ? 'localhost' : HOST}:${PORT}`);
|
||||
console.log(` ⚙️ Configure Prometheus sources at http://${HOST === '0.0.0.0' ? 'localhost' : HOST}:${PORT}/settings\n`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user