@@ -191,15 +191,18 @@ func Run(options ...RunOption) {
191
191
configureGit (cfg , childProcEnvvars )
192
192
193
193
tokenService := NewInMemoryTokenService ()
194
- tkns , err := cfg .GetTokens (true )
195
- if err != nil {
196
- log .WithError (err ).Warn ("cannot prepare tokens" )
197
- }
198
- for i := range tkns {
199
- _ , err = tokenService .SetToken (context .Background (), & tkns [i ].SetTokenRequest )
194
+
195
+ if ! opts .RunGP {
196
+ tkns , err := cfg .GetTokens (true )
200
197
if err != nil {
201
198
log .WithError (err ).Warn ("cannot prepare tokens" )
202
199
}
200
+ for i := range tkns {
201
+ _ , err = tokenService .SetToken (context .Background (), & tkns [i ].SetTokenRequest )
202
+ if err != nil {
203
+ log .WithError (err ).Warn ("cannot prepare tokens" )
204
+ }
205
+ }
203
206
}
204
207
205
208
tunneledPortsService := ports .NewTunneledPortsService (cfg .DebugEnable )
@@ -238,29 +241,41 @@ func Run(options ...RunOption) {
238
241
desktopIdeReady * ideReadyState = nil
239
242
240
243
cstate = NewInMemoryContentState (cfg .RepoRoot )
244
+ gitpodService serverapi.APIInterface
245
+
246
+ notificationService = NewNotificationService ()
247
+ )
248
+
249
+ if ! opts .RunGP {
241
250
gitpodService = serverapi .NewServerApiService (ctx , & serverapi.ServiceConfig {
242
251
Host : host ,
243
252
Endpoint : endpoint ,
244
253
InstanceID : cfg .WorkspaceInstanceID ,
245
254
WorkspaceID : cfg .WorkspaceID ,
246
255
SupervisorVersion : Version ,
247
256
}, tokenService )
257
+ }
248
258
249
- notificationService = NewNotificationService ()
250
- )
251
259
if cfg .DesktopIDE != nil {
252
260
desktopIdeReady = & ideReadyState {cond : sync .NewCond (& sync.Mutex {})}
253
261
}
254
- if ! cfg .isHeadless () {
262
+ if ! cfg .isHeadless () && ! opts . RunGP {
255
263
go trackReadiness (ctx , gitpodService , cfg , cstate , ideReady , desktopIdeReady )
256
264
}
257
265
tokenService .provider [KindGit ] = []tokenProvider {NewGitTokenProvider (gitpodService , cfg .WorkspaceConfig , notificationService )}
258
266
259
267
gitpodConfigService := config .NewConfigService (cfg .RepoRoot + "/.gitpod.yml" , cstate .ContentReady (), log .Log )
260
268
go gitpodConfigService .Watch (ctx )
261
269
270
+ var exposedPorts ports.ExposedPortsInterface
271
+
272
+ if ! opts .RunGP {
273
+ exposedPorts = createExposedPortsImpl (cfg , gitpodService )
274
+ }
275
+
276
+ // createExposedPortsImpl(cfg, gitpodService)
262
277
portMgmt := ports .NewManager (
263
- createExposedPortsImpl ( cfg , gitpodService ) ,
278
+ exposedPorts ,
264
279
& ports.PollingServedPortsObserver {
265
280
RefreshInterval : 2 * time .Second ,
266
281
},
@@ -270,7 +285,10 @@ func Run(options ...RunOption) {
270
285
)
271
286
272
287
topService := NewTopService ()
273
- topService .Observe (ctx )
288
+
289
+ if ! opts .RunGP {
290
+ topService .Observe (ctx )
291
+ }
274
292
275
293
supervisorMetrics := metrics .NewMetrics ()
276
294
var metricsReporter * metrics.GrpcMetricsReporter
@@ -355,17 +373,28 @@ func Run(options ...RunOption) {
355
373
wg sync.WaitGroup
356
374
shutdown = make (chan ShutdownReason , 1 )
357
375
)
358
- wg .Add (1 )
359
- go startContentInit (ctx , cfg , & wg , cstate , supervisorMetrics )
376
+
377
+ if ! opts .RunGP {
378
+ wg .Add (1 )
379
+ go startContentInit (ctx , cfg , & wg , cstate , supervisorMetrics )
380
+ }
381
+
360
382
wg .Add (1 )
361
383
go startAPIEndpoint (ctx , cfg , & wg , apiServices , tunneledPortsService , metricsReporter , apiEndpointOpts ... )
362
- wg .Add (1 )
363
- go startSSHServer (ctx , cfg , & wg , childProcEnvvars )
384
+
385
+ if ! opts .RunGP {
386
+ wg .Add (1 )
387
+ go startSSHServer (ctx , cfg , & wg , childProcEnvvars )
388
+ }
389
+
364
390
wg .Add (1 )
365
391
tasksSuccessChan := make (chan taskSuccess , 1 )
366
392
go taskManager .Run (ctx , & wg , tasksSuccessChan )
367
- wg .Add (1 )
368
- go socketActivationForDocker (ctx , & wg , termMux )
393
+
394
+ if ! opts .RunGP {
395
+ wg .Add (1 )
396
+ go socketActivationForDocker (ctx , & wg , termMux )
397
+ }
369
398
370
399
if cfg .isHeadless () {
371
400
wg .Add (1 )
@@ -899,7 +928,7 @@ func prepareIDELaunch(cfg *Config, ideConfig *IDEConfig, childProcEnvvars []stri
899
928
// of envvars. If envvars is nil, os.Environ() is used.
900
929
//
901
930
// Beware: if config contains an OTS URL the results may differ on subsequent calls.
902
- func buildChildProcEnv (cfg * Config , envvars []string ) []string {
931
+ func buildChildProcEnv (cfg * Config , envvars []string , runGP bool ) []string {
903
932
if envvars == nil {
904
933
envvars = os .Environ ()
905
934
}
@@ -919,7 +948,10 @@ func buildChildProcEnv(cfg *Config, envvars []string) []string {
919
948
920
949
envs [nme ] = val
921
950
}
922
- envs ["SUPERVISOR_ADDR" ] = fmt .Sprintf ("localhost:%d" , cfg .APIEndpointPort )
951
+
952
+ if ! runGP {
953
+ envs ["SUPERVISOR_ADDR" ] = fmt .Sprintf ("localhost:%d" , cfg .APIEndpointPort )
954
+ }
923
955
924
956
if cfg .EnvvarOTS != "" {
925
957
es , err := downloadEnvvarOTS (cfg .EnvvarOTS )
0 commit comments