Skip to content

Commit a5c61a7

Browse files
iQQBotroboquat
authored andcommitted
using supervisor pass IDE port to desktop IDE
1 parent 78cca2a commit a5c61a7

9 files changed

+17
-18
lines changed

components/ide/code-desktop/startup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ set -euo pipefail
88
# kill background jobs when the script exits
99
trap "jobs -p | xargs -r kill" SIGINT SIGTERM EXIT
1010

11-
/ide-desktop/status 24000 "$1" "$2"
11+
/ide-desktop/status "$1" "$2" "$3"
1212

1313
echo "Desktop IDE startup script exited"

components/ide/code-desktop/supervisor-ide-config_insiders.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"entrypoint": "/ide-desktop/startup.sh",
3-
"entrypointArgs": [ "Open in VS Code Insiders on Desktop", "vscode-insiders" ],
3+
"entrypointArgs": [ "{DESKTOPIDEPORT}", "Open in VS Code Insiders on Desktop", "vscode-insiders" ],
44
"readinessProbe": {
55
"type": "http",
66
"http": {
7-
"port": 24000,
87
"path": "/status"
98
}
109
}

components/ide/code-desktop/supervisor-ide-config_stable.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"entrypoint": "/ide-desktop/startup.sh",
3-
"entrypointArgs": [ "Open in VS Code on Desktop", "vscode" ],
3+
"entrypointArgs": [ "{DESKTOPIDEPORT}", "Open in VS Code on Desktop", "vscode" ],
44
"readinessProbe": {
55
"type": "http",
66
"http": {
7-
"port": 24000,
87
"path": "/status"
98
}
109
}

components/ide/jetbrains/image/startup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -euo pipefail
88
# kill background jobs when the script exits
99
trap "jobs -p | xargs -r kill" SIGINT SIGTERM EXIT
1010

11-
/ide-desktop/status 24000 "$1" &
11+
/ide-desktop/status "$1" "$2" &
1212

1313
echo "Desktop IDE: Waiting for the content initializer ..."
1414
until curl -sS "$SUPERVISOR_ADDR"/_supervisor/v1/status/content/wait/true | grep '"available":true' > /dev/null; do

components/ide/jetbrains/image/supervisor-ide-config_goland.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"entrypoint": "/ide-desktop/startup.sh",
3-
"entrypointArgs": [ "Open in GoLand" ],
3+
"entrypointArgs": [ "{DESKTOPIDEPORT}", "Open in GoLand" ],
44
"readinessProbe": {
55
"type": "http",
66
"http": {
7-
"port": 24000,
87
"path": "/status"
98
}
109
}

components/ide/jetbrains/image/supervisor-ide-config_intellij.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"entrypoint": "/ide-desktop/startup.sh",
3-
"entrypointArgs": [ "Open in IntelliJ IDEA" ],
3+
"entrypointArgs": [ "{DESKTOPIDEPORT}", "Open in IntelliJ IDEA" ],
44
"readinessProbe": {
55
"type": "http",
66
"http": {
7-
"port": 24000,
87
"path": "/status"
98
}
109
}

components/ide/jetbrains/image/supervisor-ide-config_phpstorm.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"entrypoint": "/ide-desktop/startup.sh",
3-
"entrypointArgs": [ "Open in PhpStorm" ],
3+
"entrypointArgs": [ "{DESKTOPIDEPORT}", "Open in PhpStorm" ],
44
"readinessProbe": {
55
"type": "http",
66
"http": {
7-
"port": 24000,
87
"path": "/status"
98
}
109
}

components/ide/jetbrains/image/supervisor-ide-config_pycharm.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"entrypoint": "/ide-desktop/startup.sh",
3-
"entrypointArgs": [ "Open in PyCharm" ],
3+
"entrypointArgs": [ "{DESKTOPIDEPORT}", "Open in PyCharm" ],
44
"readinessProbe": {
55
"type": "http",
66
"http": {
7-
"port": 24000,
87
"path": "/status"
98
}
109
}

components/supervisor/pkg/supervisor/supervisor.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const (
5959
gitpodUserName = "gitpod"
6060
gitpodGID = 33333
6161
gitpodGroupName = "gitpod"
62+
desktopIDEPort = 24000
6263
)
6364

6465
var (
@@ -192,7 +193,6 @@ func Run(options ...RunOption) {
192193
ctx, cancel := context.WithCancel(context.Background())
193194

194195
internalPorts := []uint32{uint32(cfg.IDEPort), uint32(cfg.APIEndpointPort), uint32(cfg.SSHPort)}
195-
desktopIDEPort := uint32(24000)
196196
if cfg.DesktopIDE != nil {
197197
internalPorts = append(internalPorts, desktopIDEPort)
198198
}
@@ -632,8 +632,8 @@ func launchIDE(cfg *Config, ideConfig *IDEConfig, cmd *exec.Cmd, ideStopped chan
632632
s = func() *ideStatus { i := statusShouldRun; return &i }()
633633

634634
go func() {
635-
desktopIDEStatus := runIDEReadinessProbe(cfg, ideConfig, ide)
636-
ideReady.Set(true, desktopIDEStatus)
635+
IDEStatus := runIDEReadinessProbe(cfg, ideConfig, ide)
636+
ideReady.Set(true, IDEStatus)
637637
}()
638638

639639
err = cmd.Wait()
@@ -666,6 +666,7 @@ func prepareIDELaunch(cfg *Config, ideConfig *IDEConfig) *exec.Cmd {
666666
args[i] = strings.ReplaceAll(args[i], "{WORKSPACEROOT}", cfg.WorkspaceRoot)
667667
args[i] = strings.ReplaceAll(args[i], "{IDEPORT}", strconv.Itoa(cfg.IDEPort))
668668
args[i] = strings.ReplaceAll(args[i], "{IDEHOSTNAME}", "0.0.0.0")
669+
args[i] = strings.ReplaceAll(args[i], "{DESKTOPIDEPORT}", strconv.Itoa(desktopIDEPort))
669670
}
670671
log.WithField("args", args).WithField("entrypoint", ideConfig.Entrypoint).Info("preparing IDE launch")
671672

@@ -775,6 +776,10 @@ func runIDEReadinessProbe(cfg *Config, ideConfig *IDEConfig, ide IDEKind) (deskt
775776
return value
776777
}
777778

779+
defaultProbePort := cfg.IDEPort
780+
if ide == DesktopIDE {
781+
defaultProbePort = desktopIDEPort
782+
}
778783
switch ideConfig.ReadinessProbe.Type {
779784
case ReadinessProcessProbe:
780785
return
@@ -783,7 +788,7 @@ func runIDEReadinessProbe(cfg *Config, ideConfig *IDEConfig, ide IDEKind) (deskt
783788
var (
784789
schema = defaultIfEmpty(ideConfig.ReadinessProbe.HTTPProbe.Schema, "http")
785790
host = defaultIfEmpty(ideConfig.ReadinessProbe.HTTPProbe.Host, "localhost")
786-
port = defaultIfZero(ideConfig.ReadinessProbe.HTTPProbe.Port, cfg.IDEPort)
791+
port = defaultIfZero(ideConfig.ReadinessProbe.HTTPProbe.Port, defaultProbePort)
787792
url = fmt.Sprintf("%s://%s:%d/%s", schema, host, port, strings.TrimPrefix(ideConfig.ReadinessProbe.HTTPProbe.Path, "/"))
788793
client = http.Client{Timeout: 1 * time.Second}
789794
tick = time.NewTicker(500 * time.Millisecond)

0 commit comments

Comments
 (0)