forked from MapComplete/MapComplete
		
	Add status indicator to serverLod
This commit is contained in:
		
							parent
							
								
									37c1d46dd4
								
							
						
					
					
						commit
						26adc1d06b
					
				
					 1 changed files with 11 additions and 0 deletions
				
			
		|  | @ -51,8 +51,19 @@ class ServerLdScrape extends Script { | ||||||
| 
 | 
 | ||||||
|     async main(args: string[]): Promise<void> { |     async main(args: string[]): Promise<void> { | ||||||
|         const port = Number(args[0] ?? 2346) |         const port = Number(args[0] ?? 2346) | ||||||
|  |         const start = new Date() | ||||||
|         const cache: Record<string, { date: Date; contents: any }> = {} |         const cache: Record<string, { date: Date; contents: any }> = {} | ||||||
|         new Server(port, {}, [ |         new Server(port, {}, [ | ||||||
|  |             {mustMatch: "status", | ||||||
|  |             mimetype: "application/json", | ||||||
|  |             handle: async () => { | ||||||
|  |                return JSON.stringify({ | ||||||
|  |                    online: true, | ||||||
|  |                    cached_entries: Object.keys(cache).length, | ||||||
|  |                    booted: start, | ||||||
|  |                    uptime: Math.floor((new Date().getTime() - start.getTime()) / 1000) | ||||||
|  |                }) | ||||||
|  |             }}, | ||||||
|             { |             { | ||||||
|                 mustMatch: "extractgraph", |                 mustMatch: "extractgraph", | ||||||
|                 mimetype: "application/ld+json", |                 mimetype: "application/ld+json", | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue