docker implementation
This commit is contained in:
1 parent
7c7bb45446
commit
0c2433cac6
26 files changed
+2200
-13
No files matched your search
@@ -20,8 +20,12 @@ import {
|
||||
isGlobal: true,
|
||||
}),
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'sqlite',
|
||||
database: process.env.DATABASE_PATH ?? './database.sqlite',
|
||||
type: 'postgres',
|
||||
host: process.env.DATABASE_HOST || 'localhost',
|
||||
port: parseInt(process.env.DATABASE_PORT || '5432', 10),
|
||||
username: process.env.DATABASE_USERNAME || 'placebo_user',
|
||||
password: process.env.DATABASE_PASSWORD || 'placebo_password',
|
||||
database: process.env.DATABASE_NAME || 'placebo_backend_db',
|
||||
entities: [Article, Author, Category, LiveBlog, LiveBlogUpdate],
|
||||
synchronize: process.env.NODE_ENV !== 'production',
|
||||
logging: process.env.NODE_ENV === 'development',
|
||||
|
||||
+6
-1
@@ -15,6 +15,11 @@ async function bootstrap() {
|
||||
});
|
||||
|
||||
app.setGlobalPrefix('api/v1');
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
|
||||
const port = process.env.PORT ?? 3000;
|
||||
const host = '0.0.0.0'; // Bind to all interfaces for Docker
|
||||
await app.listen(port, host);
|
||||
|
||||
console.log(`Application is running on: http://${host}:${port}`);
|
||||
}
|
||||
void bootstrap();
|
||||
@@ -223,7 +223,7 @@ export class LiveBlogUpdate {
|
||||
@Column({ nullable: true })
|
||||
authorId: string;
|
||||
|
||||
@Column({ type: 'datetime', nullable: true })
|
||||
@Column({ type: 'timestamp', nullable: true })
|
||||
scheduledAt: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
|
||||
@@ -376,8 +376,19 @@ export class LiveBlogService implements OnModuleInit {
|
||||
blogId: liveBlogId,
|
||||
});
|
||||
|
||||
// Send periodic keep-alive messages to prevent timeout
|
||||
const keepAliveInterval = setInterval(() => {
|
||||
try {
|
||||
response.write(`: keep-alive\n\n`);
|
||||
} catch (error) {
|
||||
// Client disconnected, stop sending keep-alive
|
||||
clearInterval(keepAliveInterval);
|
||||
}
|
||||
}, 15000); // Send keep-alive every 15 seconds
|
||||
|
||||
// Handle client disconnect
|
||||
response.on('close', () => {
|
||||
clearInterval(keepAliveInterval);
|
||||
this.sseClients.delete(clientId);
|
||||
this.logger.log(
|
||||
`Client ${clientId} disconnected from live blog ${liveBlogId}`,
|
||||
|
||||
Reference in new issue
Block a user