Skip to content

Commit

Permalink
[jetbrains status]: add warmup cmd
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Nogueira <[email protected]>
Co-authored-by: Anton Kosyakov <[email protected]>
  • Loading branch information
3 people authored and roboquat committed Dec 8, 2022
1 parent 77d765d commit 41e2895
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions components/ide/jetbrains/image/status/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ var (
type LaunchContext struct {
startTime time.Time

port string
alias string
label string
port string
alias string
label string
warmup bool

qualifier string
productDir string
Expand Down Expand Up @@ -89,10 +90,27 @@ func main() {
log.Info(ServiceName + ": " + Version)
startTime := time.Now()

if len(os.Args) < 3 {
log.Fatalf("Usage: %s <port> <kind> [<link label>]\n", os.Args[0])
var port string
var warmup bool

if len(os.Args) < 2 {
log.Fatalf("Usage: %s (warmup|<port>)\n", os.Args[0])
}

if os.Args[1] == "warmup" {
if len(os.Args) < 3 {
log.Fatalf("Usage: %s %s <alias>\n", os.Args[0], os.Args[1])
}

warmup = true
} else {
if len(os.Args) < 3 {
log.Fatalf("Usage: %s <port> <kind> [<link label>]\n", os.Args[0])
}

port = os.Args[1]
}
port := os.Args[1]

alias := os.Args[2]
label := "Open JetBrains IDE"
if len(os.Args) > 3 {
Expand Down Expand Up @@ -129,9 +147,10 @@ func main() {
launchCtx := &LaunchContext{
startTime: startTime,

port: port,
alias: alias,
label: label,
warmup: warmup,
port: port,
alias: alias,
label: label,

qualifier: qualifier,
productDir: productDir,
Expand All @@ -140,6 +159,11 @@ func main() {
backendVersion: backendVersion,
wsInfo: wsInfo,
}

if launchCtx.warmup {
launch(launchCtx)
return
}
// we should start serving immediately and postpone launch
// in order to enable a JB Gateway to connect as soon as possible
go launch(launchCtx)
Expand Down Expand Up @@ -423,7 +447,11 @@ func launch(launchCtx *LaunchContext) {

func run(launchCtx *LaunchContext) {
var args []string
args = append(args, "run")
if launchCtx.warmup {
args = append(args, "warmup")
} else {
args = append(args, "run")
}
args = append(args, launchCtx.projectContextDir)

cmd := remoteDevServerCmd(args, launchCtx)
Expand Down

0 comments on commit 41e2895

Please sign in to comment.