Skip to content

Commit 23e9fb5

Browse files
committed
fix(cli): add command to start controller
1 parent 689fa69 commit 23e9fb5

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.kestra.cli.commands.servers;
2+
3+
import io.kestra.core.models.ServerType;
4+
import io.kestra.core.utils.Await;
5+
import io.kestra.core.worker.Controller;
6+
import io.micronaut.context.ApplicationContext;
7+
import jakarta.inject.Inject;
8+
import picocli.CommandLine.Command;
9+
10+
import java.util.Map;
11+
12+
@Command(
13+
name = "controller",
14+
description = "Start the Kestra a controller for workers"
15+
)
16+
public class ControllerCommand extends AbstractServerCommand {
17+
18+
@Inject
19+
private ApplicationContext applicationContext;
20+
21+
@SuppressWarnings("unused")
22+
public static Map<String, Object> propertiesOverrides() {
23+
return Map.of(
24+
"kestra.server-type", ServerType.CONTROLLER
25+
);
26+
}
27+
28+
@Override
29+
public Integer call() throws Exception {
30+
super.call();
31+
32+
Controller controller = applicationContext.getBean(Controller.class);
33+
controller.start();
34+
35+
Await.until(() -> !this.applicationContext.isRunning());
36+
37+
return 0;
38+
}
39+
}

cli/src/main/java/io/kestra/cli/commands/servers/ServerCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
StandAloneCommand.class,
1818
WebServerCommand.class,
1919
WorkerCommand.class,
20+
ControllerCommand.class,
2021
LocalCommand.class
2122
}
2223
)

cli/src/test/java/io/kestra/cli/AppTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void testHelp() {
3131
}
3232

3333
@ParameterizedTest
34-
@ValueSource(strings = {"standalone", "executor", "indexer", "scheduler", "webserver", "worker", "local"})
34+
@ValueSource(strings = {"standalone", "executor", "indexer", "scheduler", "webserver", "worker", "controller", "local"})
3535
void testServerCommandHelp(String serverType) {
3636
final ByteArrayOutputStream out = new ByteArrayOutputStream();
3737
System.setOut(new PrintStream(out));

0 commit comments

Comments
 (0)