Skip to content
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

Add hostname arg to cli parser #214

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ public static void main(final String[] args) {
ElkLayoutEngine.initialize(new LayeredMetaDataProvider());

int port = parser.parsePort();
String host = parser.parseHostname();
ServerModule workflowServerModule = new WorkflowServerModule()
.configureDiagramModule(new WorkflowDiagramModule());

GLSPServerLauncher launcher = parser.isWebsocket()
? new WebsocketServerLauncher(workflowServerModule, "/workflow", parser.parseWebsocketLogLevel())
: new SocketGLSPServerLauncher(workflowServerModule);

launcher.start("localhost", port, parser);
launcher.start(host, port, parser);

} catch (ParseException ex) {
ex.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
public class DefaultCLIParser extends CLIParser {
public static final String OPTION_HELP = "help";
public static final String OPTION_PORT = "port";
public static final String OPTION_HOST_NAME = "host";
public static final String OPTION_CONSOLE_LOG = "consoleLog";
public static final String OPTION_FILE_LOG = "fileLog";
public static final String OPTION_LOG_LEVEL = "logLevel";
Expand All @@ -45,6 +46,10 @@ public int parsePort() {
return parseIntOption(OPTION_PORT, DefaultOptions.SERVER_PORT, validator);
}

public String parseHostname() {
return parseOption(OPTION_HOST_NAME, DefaultOptions.HOST_NAME);
}

public String parseLogDir() {
Predicate<String> validator = (logDirArg) -> {
File file = new File(logDirArg);
Expand All @@ -68,6 +73,8 @@ public Level parseLogLevel() {
public static Options getDefaultOptions() {
Options options = new Options();
options.addOption("h", OPTION_HELP, false, "Display usage information about GLSPServerLauncher");
options.addOption("n", OPTION_HOST_NAME, true, String.format("Set server host name. [default='%s']",
DefaultOptions.HOST_NAME));
options.addOption("p", OPTION_PORT, true,
String.format("Set server port. [default='%s']", DefaultOptions.SERVER_PORT));
options.addOption("c", OPTION_CONSOLE_LOG, true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private LaunchUtil() {}

public static final class DefaultOptions {
public static final int SERVER_PORT = 0;
public static final String HOST_NAME = "127.0.0.1";
public static final Level LOG_LEVEL = Level.INFO;
public static final String LOG_DIR = new File("./logs/").getAbsolutePath();
public static final boolean CONSOLE_LOG_ENABLED = true;
Expand Down
Loading