App-aep

 view release on metacpan or  search on metacpan

bin/aep  view on Meta::CPAN

#!/usr/bin/env perl

# Core
use warnings;
use strict;
use utf8;
use v5.28;

# Experimental (stable)
use experimental 'signatures';

# External modules
use YAML::XS;
use Getopt::Long::Descriptive;
use POE qw(Session::PlainCall);

# Our modules
use App::aep;

# Debug
use Data::Dumper;
use Carp qw(cluck longmess shortmess);

STDOUT->autoflush(1);
STDERR->autoflush(1);

# Version of this software
our $VERSION = '0.013';

# Config defaults
my $opt_conf_def = { 'AEP_SOCKETPATH' => '/tmp/aep.sock', };

# Option specs
my @opt_desc = (
    'aep %o <some-arg>',
    [
        'config-env',
        'Read config values from the environment only.',
        {
            'default' => 0,
        },
    ],
    [
        'config-file=s',
        'Read config from a config file only.',
        {
            'default'   => '$unset',
            'callbacks' => {
                'exists' => sub { _check_exists( shift ) },
            },
        },
    ],
    [
        'config-args',
        'Read config values from arguments only.',
        {
            'default' => 0,
        },
    ],
    [
        'config-merge',
        'Merge together env, file and args to generate a config.',
        {
            'default' => 1,
        },
    ],
    [
        'config-order=s',
        'The order to merge options together, comma separated, default is: env,file,args',
        {
            'default' => 'env,file,args',
        },
    ],
    [],
    [
        'env-prefix=s',
        'What prefix to look for aep config environmentals, default is AEP_',
        {
            'default' => 'AEP_',
        },
    ],
    [],
    [
        'command=s',
        'What to actually run within the container, default is print aes help.',
        {
            'default' => 'aep --help',
        }
    ],
    [
        'command-args=s',
        'The arguments to add to the command comma separated, default is nothing.',
        {
            'default' => "",
        },
    ],
    [ 'command-norestart', 'If the command exits then do not attempt to restart it.', ],
    [
        'command-restart=i',
        'If the command exits how many times to retry it, default 0. Set to -1 for infinite.',
        {
            'default'   => 0,
            'callbacks' => {
                'is_positive' => sub { _check_positive_number( shift ) },
            },
        },
    ],
    [
        'command-restart-delay=i',
        'The time in milliseconds to wait before retrying the command, default 1000',
        {
            'default' => 1000,
        },
    ],
    [],
    [
        'lock-server',
        'Act like a lock server, this means we will expect other apps to '
        . 'connect to us, we in turn will say when they should actually start, '
        . 'this is to counter-act race issues when starting multi image '
        . 'containers such as docker-compose, default: no',
        {
            'default' => 0,
        },
    ],
    [
        'lock-server-host=s',
        'What host to bind to, defaults to 0.0.0.0',
        {
            'default' => '0.0.0.0',
        },
    ],
    [
        'lock-server-port=i',
        'What port to bind to, defaults to 60000',
        {
            'default' => 60000,
        },
    ],
    [
        'lock-server-default=s',
        'If we get sent an ID we do not know, the default action to take. '
        . 'Valid options are: "ignore", "run" or "runlast" the default is ignore.',
        {
            'default' => 'ignore',
        },
    ],
    [
        'lock-server-order=s',
        'The list of ids and the order to allow them to run, '
        . 'comma separated. Use || for parallel groups, e.g.: db,redis1||redis2,nginx',
        {
            'default' => '',
        },
    ],
    [
        'lock-server-exhaust-action=s',
        'What to do when all clients in the order have started. '
        . 'Valid options: "exit", "idle", "restart", "execute". Default is idle.',
        {
            'default' => 'idle',
        },
    ],



( run in 2.161 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )