Search in sources :

Example 1 with ArtipieYaml

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);
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) IOException(java.io.IOException) File(java.io.File) ArtipieYaml(com.artipie.front.settings.ArtipieYaml) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

ArtipieYaml (com.artipie.front.settings.ArtipieYaml)1 File (java.io.File)1 IOException (java.io.IOException)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 HelpFormatter (org.apache.commons.cli.HelpFormatter)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1