2026-07-21 15:28:55 +08:00
|
|
|
/**
|
|
|
|
|
* local server entry file, for local development
|
|
|
|
|
*/
|
|
|
|
|
import app from './app.js';
|
|
|
|
|
import { closeDatabase } from './database.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* start server with port
|
|
|
|
|
*/
|
2026-07-21 17:13:08 +08:00
|
|
|
const PORT = process.env.PORT || 3010;
|
2026-07-21 15:28:55 +08:00
|
|
|
|
|
|
|
|
const server = app.listen(PORT, () => {
|
|
|
|
|
console.log(`Server ready on port ${PORT}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* close server
|
|
|
|
|
*/
|
|
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
|
console.log('SIGTERM signal received');
|
|
|
|
|
server.close(async () => {
|
|
|
|
|
await closeDatabase();
|
|
|
|
|
console.log('Server closed');
|
|
|
|
|
process.exit(0);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
process.on('SIGINT', () => {
|
|
|
|
|
console.log('SIGINT signal received');
|
|
|
|
|
server.close(async () => {
|
|
|
|
|
await closeDatabase();
|
|
|
|
|
console.log('Server closed');
|
|
|
|
|
process.exit(0);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default app;
|