@@ -36,8 +36,6 @@ import { NewsletterSubscriptionController } from "./user/newsletter-subscription
3636import { Config } from "./config" ;
3737import { DebugApp } from "@gitpod/gitpod-protocol/lib/util/debug-app" ;
3838import { WsConnectionHandler } from "./express/ws-connection-handler" ;
39- import { LivenessController } from "./liveness/liveness-controller" ;
40- import { ReadinessController } from "./liveness/readiness-controller" ;
4139import { IamSessionApp } from "./iam/iam-session-app" ;
4240import { API } from "./api/server" ;
4341import { GithubApp } from "./prebuilds/github-app" ;
@@ -54,6 +52,11 @@ import {
5452} from "./workspace/headless-log-service" ;
5553import { runWithRequestContext } from "./util/request-context" ;
5654import { AnalyticsController } from "./analytics-controller" ;
55+ import { ProbesApp as ProbesAppProvider } from "./liveness/probes" ;
56+
57+ const MONITORING_PORT = 9500 ;
58+ const IAM_SESSION_PORT = 9876 ;
59+ const PROBES_PORT = 9400 ;
5760
5861@injectable ( )
5962export class Server {
@@ -66,6 +69,8 @@ export class Server {
6669 protected privateApiServer ?: http . Server ;
6770
6871 protected readonly eventEmitter = new EventEmitter ( ) ;
72+ protected probesApp : express . Application ;
73+ protected probesServer ?: http . Server ;
6974 protected app ?: express . Application ;
7075 protected httpServer ?: http . Server ;
7176 protected monitoringApp ?: express . Application ;
@@ -80,8 +85,6 @@ export class Server {
8085 @inject ( UserController ) private readonly userController : UserController ,
8186 @inject ( WebsocketConnectionManager ) private readonly websocketConnectionHandler : WebsocketConnectionManager ,
8287 @inject ( WorkspaceDownloadService ) private readonly workspaceDownloadService : WorkspaceDownloadService ,
83- @inject ( LivenessController ) private readonly livenessController : LivenessController ,
84- @inject ( ReadinessController ) private readonly readinessController : ReadinessController ,
8588 @inject ( MonitoringEndpointsApp ) private readonly monitoringEndpointsApp : MonitoringEndpointsApp ,
8689 @inject ( CodeSyncService ) private readonly codeSyncService : CodeSyncService ,
8790 @inject ( HeadlessLogController ) private readonly headlessLogController : HeadlessLogController ,
@@ -102,6 +105,7 @@ export class Server {
102105 @inject ( API ) private readonly api : API ,
103106 @inject ( RedisSubscriber ) private readonly redisSubscriber : RedisSubscriber ,
104107 @inject ( AnalyticsController ) private readonly analyticsController : AnalyticsController ,
108+ @inject ( ProbesAppProvider ) private readonly probesAppProvider : ProbesAppProvider ,
105109 ) { }
106110
107111 public async init ( app : express . Application ) {
@@ -115,6 +119,9 @@ export class Server {
115119 await this . typeOrm . connect ( ) ;
116120 log . info ( "connected to DB" ) ;
117121
122+ // probes
123+ this . probesApp = this . probesAppProvider . create ( ) ;
124+
118125 // metrics
119126 app . use ( ( req : express . Request , res : express . Response , next : express . NextFunction ) => {
120127 const startTime = Date . now ( ) ;
@@ -321,8 +328,6 @@ export class Server {
321328 // Authorization: none
322329 app . use ( this . oneTimeSecretServer . apiRouter ) ;
323330 app . use ( this . newsletterSubscriptionController . apiRouter ) ;
324- app . use ( "/live" , this . livenessController . apiRouter ) ;
325- app . use ( "/ready" , this . readinessController . apiRouter ) ;
326331 app . use ( "/version" , ( req : express . Request , res : express . Response , next : express . NextFunction ) => {
327332 res . send ( this . config . version ) ;
328333 } ) ;
@@ -354,22 +359,27 @@ export class Server {
354359 throw new Error ( "server cannot start, not initialized" ) ;
355360 }
356361
362+ const probeServer = this . probesApp . listen ( PROBES_PORT , ( ) => {
363+ log . info ( `probes server listening on port: ${ ( < AddressInfo > probeServer . address ( ) ) . port } ` ) ;
364+ } ) ;
365+ this . probesServer = probeServer ;
366+
357367 const httpServer = this . app . listen ( port , ( ) => {
358368 this . eventEmitter . emit ( Server . EVENT_ON_START , httpServer ) ;
359369 log . info ( `server listening on port: ${ ( < AddressInfo > httpServer . address ( ) ) . port } ` ) ;
360370 } ) ;
361371 this . httpServer = httpServer ;
362372
363373 if ( this . monitoringApp ) {
364- this . monitoringHttpServer = this . monitoringApp . listen ( 9500 , "localhost" , ( ) => {
374+ this . monitoringHttpServer = this . monitoringApp . listen ( MONITORING_PORT , "localhost" , ( ) => {
365375 log . info (
366376 `monitoring app listening on port: ${ ( < AddressInfo > this . monitoringHttpServer ! . address ( ) ) . port } ` ,
367377 ) ;
368378 } ) ;
369379 }
370380
371381 if ( this . iamSessionApp ) {
372- this . iamSessionAppServer = this . iamSessionApp . listen ( 9876 , ( ) => {
382+ this . iamSessionAppServer = this . iamSessionApp . listen ( IAM_SESSION_PORT , ( ) => {
373383 log . info (
374384 `IAM session server listening on port: ${ ( < AddressInfo > this . iamSessionAppServer ! . address ( ) ) . port } ` ,
375385 ) ;
@@ -409,6 +419,7 @@ export class Server {
409419 race ( this . stopServer ( this . httpServer ) , "stop httpserver" ) ,
410420 race ( this . stopServer ( this . privateApiServer ) , "stop private api server" ) ,
411421 race ( this . stopServer ( this . publicApiServer ) , "stop public api server" ) ,
422+ race ( this . stopServer ( this . probesServer ) , "stop probe server" ) ,
412423 race ( ( async ( ) => this . disposables . dispose ( ) ) ( ) , "dispose disposables" ) ,
413424 ] ) ;
414425
0 commit comments