Skip to content

Commit aa3d2e8

Browse files
authored
Starting Zilla with the CLI improvement (#1042)
1 parent 12b8c92 commit aa3d2e8

3 files changed

Lines changed: 27 additions & 15 deletions

File tree

manager/src/main/java/io/aklivity/zilla/manager/internal/commands/install/ZpmInstall.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,10 @@ private void generateLauncher() throws IOException
749749
"if [ -n \"$ZILLA_INCUBATOR_ENABLED\" ]; then",
750750
"JAVA_OPTIONS=\"$JAVA_OPTIONS -Dzilla.incubator.enabled=$ZILLA_INCUBATOR_ENABLED\"",
751751
"fi",
752-
"cd \"${0%/*}\"",
752+
"ZILLA_DIRECTORY=\"${0%/*}\"",
753+
"JAVA_OPTIONS=\"$JAVA_OPTIONS -Dzilla.directory=$ZILLA_DIRECTORY\"",
753754
String.format(String.join(" ", Arrays.asList(
754-
"exec %s/bin/java",
755+
"exec $ZILLA_DIRECTORY/%s/bin/java",
755756
"--add-opens java.base/sun.nio.ch=org.agrona.core",
756757
"$JAVA_OPTIONS",
757758
"-m io.aklivity.zilla.runtime.command/io.aklivity.zilla.runtime.command.internal.ZillaMain \"$@\"")),

runtime/command-start/src/main/java/io/aklivity/zilla/runtime/command/start/internal/airline/ZillaStartCommand.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_DIRECTORY;
2020
import static io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_VERBOSE;
2121
import static io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_WORKERS;
22+
import static io.aklivity.zilla.runtime.engine.EngineConfiguration.ZILLA_DIRECTORY_PROPERTY;
2223
import static java.lang.Runtime.getRuntime;
2324
import static org.agrona.LangUtil.rethrowUnchecked;
2425

@@ -45,14 +46,15 @@
4546
@Command(name = "start", description = "Start engine")
4647
public final class ZillaStartCommand extends ZillaCommand
4748
{
48-
private static final String OPTION_PROPERTIES_PATH_DEFAULT = ".zilla/zilla.properties";
49+
private static final String ZILLA_DIRECTORY = System.getProperty(ZILLA_DIRECTORY_PROPERTY, ".");
50+
private static final String OPTION_PROPERTIES_PATH_DEFAULT = String.format("%s/.zilla/zilla.properties", ZILLA_DIRECTORY);
51+
private static final String ZILLA_ENGINE_PATH_DEFAULT = String.format("%s/.zilla/engine", ZILLA_DIRECTORY);
4952

5053
private final CountDownLatch stop = new CountDownLatch(1);
5154
private final CountDownLatch stopped = new CountDownLatch(1);
5255

5356
@Option(name = {"-c", "--config"},
54-
description = "Configuration location",
55-
hidden = true)
57+
description = "Configuration location")
5658
public URI configURI;
5759

5860
@Option(name = {"-v", "--verbose"},
@@ -64,26 +66,23 @@ public final class ZillaStartCommand extends ZillaCommand
6466
public int workers = -1;
6567

6668
@Option(name = {"-P", "--property"},
67-
description = "Property name=value",
68-
hidden = true)
69+
description = "Property name=value")
6970
public List<String> properties;
7071

7172
@Option(name = {"-p", "--properties"},
72-
description = "Path to properties",
73-
hidden = true)
73+
description = "Path to properties")
7474
public String propertiesPath;
7575

76-
@Option(name = "-e",
77-
description = "Show exception traces",
78-
hidden = true)
76+
@Option(name = {"-e", "--exception-traces"},
77+
description = "Show exception traces")
7978
public boolean exceptions;
8079

8180
@Override
8281
public void run()
8382
{
8483
Runtime runtime = getRuntime();
8584
Properties props = new Properties();
86-
props.setProperty(ENGINE_DIRECTORY.name(), ".zilla/engine");
85+
props.setProperty(ENGINE_DIRECTORY.name(), ZILLA_ENGINE_PATH_DEFAULT);
8786

8887
Path path = Paths.get(propertiesPath != null ? propertiesPath : OPTION_PROPERTIES_PATH_DEFAULT);
8988
if (Files.exists(path) || propertiesPath != null)

runtime/engine/src/main/java/io/aklivity/zilla/runtime/engine/EngineConfiguration.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
public class EngineConfiguration extends Configuration
4040
{
4141
public static final String ZILLA_NAME_PROPERTY = "zilla.name";
42+
public static final String ZILLA_DIRECTORY_PROPERTY = "zilla.directory";
4243

4344
public static final boolean DEBUG_BUDGETS = Boolean.getBoolean("zilla.engine.debug.budgets");
4445

@@ -82,7 +83,7 @@ public class EngineConfiguration extends Configuration
8283
ENGINE_CONFIG_URL = config.property(URL.class, "config.url", EngineConfiguration::configURL, "file:zilla.yaml");
8384
ENGINE_CONFIG_POLL_INTERVAL_SECONDS = config.property("config.poll.interval.seconds", 60);
8485
ENGINE_NAME = config.property("name", EngineConfiguration::defaultName);
85-
ENGINE_DIRECTORY = config.property("directory", ".");
86+
ENGINE_DIRECTORY = config.property("directory", EngineConfiguration::defaultDirectory);
8687
ENGINE_CACHE_DIRECTORY = config.property(Path.class, "cache.directory", EngineConfiguration::cacheDirectory, "cache");
8788
ENGINE_HOST_RESOLVER = config.property(HostResolver.class, "host.resolver",
8889
EngineConfiguration::decodeHostResolver, EngineConfiguration::defaultHostResolver);
@@ -319,7 +320,12 @@ private static URL configURL(
319320
URL configURL = null;
320321
try
321322
{
322-
configURL = URI.create(url).toURL();
323+
URI uri = URI.create(url);
324+
if (uri.getScheme() == null)
325+
{
326+
uri = URI.create(String.format("file:%s", url));
327+
}
328+
configURL = uri.toURL();
323329
}
324330
catch (MalformedURLException ex)
325331
{
@@ -348,6 +354,12 @@ private static String defaultName(
348354
return System.getProperty(ZILLA_NAME_PROPERTY, "zilla");
349355
}
350356

357+
private static String defaultDirectory(
358+
Configuration config)
359+
{
360+
return System.getProperty(ZILLA_DIRECTORY_PROPERTY, ".");
361+
}
362+
351363
private static HostResolver decodeHostResolver(
352364
Configuration config,
353365
String value)

0 commit comments

Comments
 (0)