use of com.artipie.front.settings.ArtipieYaml in project front by artipie.
the class Service method main.
/**
* Entry point.
* @param args CLA
* @throws ParseException If cli line argument has wrong format
*/
@SuppressWarnings("PMD.DoNotCallSystemExit")
public static void main(final String... args) throws ParseException {
final Options options = new Options();
options.addOption(Service.PORT);
options.addOption(Service.CONFIG);
final CommandLineParser parser = new DefaultParser();
final CommandLine cmd;
try {
cmd = parser.parse(options, args);
final var service = new Service(new ArtipieYaml(Yaml.createYamlInput(new File(cmd.getOptionValue(Service.CONFIG))).readYamlMapping()));
service.start(Integer.parseInt(cmd.getOptionValue(Service.PORT, "8080")));
Runtime.getRuntime().addShutdownHook(new Thread(service::stop, "shutdown"));
} catch (final ParseException ex) {
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("com.artipie.front.Service", options);
throw ex;
} catch (final IOException ex) {
Logger.error(Service.class, "Failed to read artipie setting yaml");
System.exit(1);
}
}
Aggregations