mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 15:34:13 +00:00 
			
		
		
		
	merge: Synchronize app startup (!788)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/788 Approved-by: Marie <github@yuugi.dev> Approved-by: dakkar <dakkar@thenautilus.net>
This commit is contained in:
		
						commit
						a754a9947b
					
				
					 3 changed files with 12 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -19,17 +19,18 @@ export async function server() {
 | 
			
		|||
		logger: new NestLogger(),
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	const serverService = app.get(ServerService);
 | 
			
		||||
	await serverService.launch();
 | 
			
		||||
 | 
			
		||||
	if (process.env.NODE_ENV !== 'test') {
 | 
			
		||||
		app.get(ChartManagementService).start();
 | 
			
		||||
		await app.get(ChartManagementService).start();
 | 
			
		||||
	}
 | 
			
		||||
	if (!envOption.noDaemons) {
 | 
			
		||||
		app.get(QueueStatsService).start();
 | 
			
		||||
		app.get(ServerStatsService).start();
 | 
			
		||||
		await app.get(QueueStatsService).start();
 | 
			
		||||
		await app.get(ServerStatsService).start();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Start server last so the other services can register hooks first
 | 
			
		||||
	const serverService = app.get(ServerService);
 | 
			
		||||
	await serverService.launch();
 | 
			
		||||
 | 
			
		||||
	return app;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -38,8 +39,8 @@ export async function jobQueue() {
 | 
			
		|||
		logger: new NestLogger(),
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	jobQueue.get(QueueProcessorService).start();
 | 
			
		||||
	jobQueue.get(ChartManagementService).start();
 | 
			
		||||
	await jobQueue.get(QueueProcessorService).start();
 | 
			
		||||
	await jobQueue.get(ChartManagementService).start();
 | 
			
		||||
 | 
			
		||||
	return jobQueue;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ export class QueueStatsService implements OnApplicationShutdown {
 | 
			
		|||
	 * Report queue stats regularly
 | 
			
		||||
	 */
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public start(): void {
 | 
			
		||||
	public async start(): Promise<void> {
 | 
			
		||||
		const log = [] as any[];
 | 
			
		||||
 | 
			
		||||
		ev.on('requestQueueStatsLog', x => {
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +82,7 @@ export class QueueStatsService implements OnApplicationShutdown {
 | 
			
		|||
			activeInboxJobs = 0;
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		tick();
 | 
			
		||||
		await tick();
 | 
			
		||||
 | 
			
		||||
		this.intervalId = setInterval(tick, interval);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -68,7 +68,7 @@ export class ServerStatsService implements OnApplicationShutdown {
 | 
			
		|||
			if (log.length > 200) log.pop();
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		tick();
 | 
			
		||||
		await tick();
 | 
			
		||||
 | 
			
		||||
		this.intervalId = setInterval(tick, interval);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue