Skip to content

[jetbrains launcher] introduce backward compatible warmup command #15243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think warmup is the first arg here

}

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