Skip to content

Commit b702f97

Browse files
Andrea Falzettifelladrinakosyakov
committed
[jetbrains status]: add warmup cmd
Co-authored-by: Victor Nogueira <[email protected]> Co-authored-by: Anton Kosyakov <[email protected]>
1 parent 2cf5dc7 commit b702f97

File tree

1 file changed

+38
-10
lines changed
  • components/ide/jetbrains/image/status

1 file changed

+38
-10
lines changed

components/ide/jetbrains/image/status/main.go

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ var (
5050
type LaunchContext struct {
5151
startTime time.Time
5252

53-
port string
54-
alias string
55-
label string
53+
port string
54+
alias string
55+
label string
56+
warmup bool
5657

5758
qualifier string
5859
productDir string
@@ -89,10 +90,27 @@ func main() {
8990
log.Info(ServiceName + ": " + Version)
9091
startTime := time.Now()
9192

92-
if len(os.Args) < 3 {
93-
log.Fatalf("Usage: %s <port> <kind> [<link label>]\n", os.Args[0])
93+
var port string
94+
var warmup bool
95+
96+
if len(os.Args) < 2 {
97+
log.Fatalf("Usage: %s (warmup|<port>)\n", os.Args[0])
98+
}
99+
100+
if os.Args[1] == "warmup" {
101+
if len(os.Args) < 3 {
102+
log.Fatalf("Usage: %s %s <alias>\n", os.Args[0], os.Args[1])
103+
}
104+
105+
warmup = true
106+
} else {
107+
if len(os.Args) < 3 {
108+
log.Fatalf("Usage: %s <port> <kind> [<link label>]\n", os.Args[0])
109+
}
110+
111+
port = os.Args[1]
94112
}
95-
port := os.Args[1]
113+
96114
alias := os.Args[2]
97115
label := "Open JetBrains IDE"
98116
if len(os.Args) > 3 {
@@ -129,9 +147,10 @@ func main() {
129147
launchCtx := &LaunchContext{
130148
startTime: startTime,
131149

132-
port: port,
133-
alias: alias,
134-
label: label,
150+
warmup: warmup,
151+
port: port,
152+
alias: alias,
153+
label: label,
135154

136155
qualifier: qualifier,
137156
productDir: productDir,
@@ -140,6 +159,11 @@ func main() {
140159
backendVersion: backendVersion,
141160
wsInfo: wsInfo,
142161
}
162+
163+
if launchCtx.warmup {
164+
launch(launchCtx)
165+
return
166+
}
143167
// we should start serving immediately and postpone launch
144168
// in order to enable a JB Gateway to connect as soon as possible
145169
go launch(launchCtx)
@@ -423,7 +447,11 @@ func launch(launchCtx *LaunchContext) {
423447

424448
func run(launchCtx *LaunchContext) {
425449
var args []string
426-
args = append(args, "run")
450+
if launchCtx.warmup {
451+
args = append(args, "warmup")
452+
} else {
453+
args = append(args, "run")
454+
}
427455
args = append(args, launchCtx.projectContextDir)
428456

429457
cmd := remoteDevServerCmd(args, launchCtx)

0 commit comments

Comments
 (0)