<commit_before>package Artemis::Reports::API::Daemon;

use 5.010;

use strict;
use warnings;

use Artemis::Reports::API;
use Method::Signatures;
use Moose;

with 'MooseX::Daemonize';

has server => (is => 'rw');
has port   => (is => 'rw', isa => 'Int', default => 7358);

after start => sub {
                    my $self = shift;

                    return unless $self->is_daemon;

                    $self->initialize_server;
                    $self->server->server_loop;
                   }
;

method initialize_server
{
        my $EUID = `id -u`; chomp $EUID;
        my $EGID = `id -g`; chomp $EGID;
        Artemis::Reports::API->run(
                                   port         => $self->port,
                                   log_level    => 2,
                                   max_servers  => 2,
                                   max_requests => 2,
                                   user         => $EUID,
                                   group        => $EGID,
                                  );
}
;

method run
{
        my ($command) = @ARGV;
        return unless $command && grep /^$command$/, qw(start status restart stop);
        $self->$command;
        say $self->status_message;
}
;


1;<commit_msg>- allow explicit command to daemon run() method<commit_after>package Artemis::Reports::API::Daemon;

use 5.010;

use strict;
use warnings;

use Artemis::Reports::API;
use Method::Signatures;
use Moose;

with 'MooseX::Daemonize';

has server => (is => 'rw');
has port   => (is => 'rw', isa => 'Int', default => 7358);

after start => sub {
                    my $self = shift;

                    return unless $self->is_daemon;

                    $self->initialize_server;
                    $self->server->server_loop;
                   }
;

method initialize_server
{
        my $EUID = `id -u`; chomp $EUID;
        my $EGID = `id -g`; chomp $EGID;
        Artemis::Reports::API->run(
                                   port         => $self->port,
                                   log_level    => 2,
                                   max_servers  => 2,
                                   max_requests => 2,
                                   user         => $EUID,
                                   group        => $EGID,
                                  );
}
;

method run
{
        my ($command) = @ARGV || @_;
        say STDERR "Boo boo 1! command = $command";
        return unless $command && grep /^$command$/, qw(start status restart stop);
        $self->$command;
        say $self->status_message;
}
;


1;
{'fraction_non_alphanumeric': 0.12752721617418353, 'fraction_numerical': 0.009720062208398134, 'mean_word_length': 1.2277056277056277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '106385', 'n_tokens_mistral': 787, 'n_tokens_neox': 722, 'n_words': 181}