| 1 | package Langertha::Knarr::CLI::Cmd::Start; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 39 | our $VERSION = '1.103'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Start the Knarr proxy server | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 39 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 39 | with 'Langertha::Knarr::CLI::Role::GlobalOptions'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 39 | ▶ | use MooX::Cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 39 | ▶ | use MooX::Options protect_argv => 0, usage_string => 'USAGE: knarr start [options]'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 39 | ▶ | use Log::Any qw( $log ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 39 | ▶ | use Log::Any::Adapter; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | option port => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | format => 'i@', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | short => 'p', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | doc => 'Port(s) to listen on, on the -H host; repeatable, replaces the config listen: (default: the config listen:, which defaults to 127.0.0.1:8080 and 127.0.0.1:11434)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 15 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 39 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 39 | option host => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | format => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | short => 'H', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | doc => 'Host the -p ports bind to, no effect without -p (default: 0.0.0.0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | default => '0.0.0.0', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 39 | option workers => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | format => 'i', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | short => 'w', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | doc => 'Number of worker processes; more than 1 forks that many, supervised and restarted by this process (default: the config workers:, else KNARR_WORKERS, else 1, no fork)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | predicate => 'has_workers', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 39 | option from_env => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | doc => 'Build config from environment variables when no config file found', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 39 | option remote_config => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | doc => 'Allow a start without models; the routing setup comes from PUT /knarr/admin/config, layered over the config file, held in memory (needs KNARR_ADMIN_KEY; or remote_config: / KNARR_REMOTE_CONFIG)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 39 | option trace_name => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | format => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | short => 'n', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | doc => 'Langfuse trace name (default: knarr-proxy, or KNARR_TRACE_NAME env)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | predicate => 'has_trace_name', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 39 | option log_file => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | format => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | doc => 'JSONL log file path (or KNARR_LOG_FILE env)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | predicate => 'has_log_file', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 39 | option log_dir => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | format => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | doc => 'Directory for per-request JSON log files (or KNARR_LOG_DIR env)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | predicate => 'has_log_dir', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=71 SCAR=83.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $verbose = $self->verbose_enabled($chain); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | ▶ | Log::Any::Adapter->set('Stderr', log_level => $verbose ? 'trace' : 'warning'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | require Langertha::Knarr::Config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | my $config_file = $self->config_file($chain); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my $config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # KNARR_REMOTE_CONFIG, read the way the config reads it (k75). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | my $remote_config_requested = $self->remote_config | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->remote_config || 'Langertha::Knarr::Config'->new('data', {})->remote_config
MC/DC0%0/2
$self->remote_config || 'Langertha::Knarr::Config'->new('data', {})->remote_config
$self->remote_config
'Langertha::Knarr::Config'->new('data', {})->remote_config
Truth table33%1/3
A || B
A= $self->remote_configB= 'Langertha::Knarr::Config'->new('data', {})->remote_config
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | || Langertha::Knarr::Config->new( data => {} )->remote_config; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | if (-f $config_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | $config = Langertha::Knarr::Config->new(file => $config_file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | $config->data->{remote_config} = 1 if $self->remote_config; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | my @errors = $config->validate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | if (@errors) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | _err("Configuration errors:"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | _err(" - $_") for @errors; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | _log("Config: loaded from $config_file"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } elsif ($remote_config_requested) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # The setup arrives by admin push; nothing to read, not even the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # environment's provider keys (--from-env is the Docker default). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $config = Langertha::Knarr::Config->new( data => { remote_config => 1 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my @errors = $config->validate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (@errors) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | _err("Configuration errors:"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | _err(" - $_") for @errors; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | _log("Config: remote config, no config file" . ( $self->from_env ? " (--from-env ignored)" : '' )); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } elsif ($self->from_env) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | _log("Config: auto-detecting from environment variables"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $config = Langertha::Knarr::Config->from_env(include_test => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Not validated as a whole (no keys found is passthrough-only mode), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # but an admin key must still hold (k75). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ( my @errors = $config->admin_errors ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | _err("Configuration errors:"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | _err(" - $_") for @errors; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | print STDERR "Config file not found: $config_file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | print STDERR " knarr init > knarr.yaml Generate a config from your environment\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | print STDERR " knarr start --from-env Auto-detect config from environment variables\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $workers = $self->_workers($config); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $remote_config = $config->remote_config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $admin_on = $config->has_admin_key; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ( $admin_on && $workers > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$admin_on and $workers > 1
MC/DC0%0/2
$admin_on and $workers > 1
$admin_on
$workers > 1
Truth table0%0/3
A and B
A= $admin_onB= $workers > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | _log("WARNING: workers forced to 1 (was $workers): the admin routes keep the" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | . " delivered setup in this process's memory, a push would reach one worker only"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $workers = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # Inject CLI trace_name into config | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ($self->has_trace_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | $config->data->{langfuse} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->data->{"langfuse"} //= {}
MC/DC0%0/1
$config->data->{"langfuse"} //= {}
$config->data->{"langfuse"}
Truth table0%0/2
A
A= $config->data->{"langfuse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $config->data->{langfuse}{trace_name} = $self->trace_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # Inject CLI logging options into config | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ($self->has_log_file || $self->has_log_dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->has_log_file or $self->has_log_dir
MC/DC0%0/2
$self->has_log_file or $self->has_log_dir
$self->has_log_file
$self->has_log_dir
Truth table0%0/3
A or B
A= $self->has_log_fileB= $self->has_log_dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | $config->data->{logging} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->data->{"logging"} //= {}
MC/DC0%0/1
$config->data->{"logging"} //= {}
$config->data->{"logging"}
Truth table0%0/2
A
A= $config->data->{"logging"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $config->data->{logging}{file} = $self->log_file if $self->has_log_file; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | $config->data->{logging}{dir} = $self->log_dir if $self->has_log_dir; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # Build listen addresses | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $listen_addrs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $h = $self->host; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my @ports = @{ $self->port }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if (@ports) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $listen_addrs = [ map { "$h:$_" } @ports ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } elsif (my $cfg_listen = $config->listen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $listen_addrs = $cfg_listen; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $listen_addrs = [ "$h:8080", "$h:11434" ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # Startup banner | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | _log("Knarr LLM Proxy starting..."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | _log(""); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # Log discovered engines and models | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $models = $config->models; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $model_count = scalar keys %$models; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $token_auth = $config->token_auth; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ($token_auth) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # Which backend and routes; never the dsn, user, password or relation. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | _log("Auth: token_auth ($token_auth->{backend}, routes: " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | . join( ', ', sort keys %{ $config->routes } ) . ")"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | _log("Engines: none configured, models come from the tokens"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | } elsif ( $remote_config && !$model_count && !$config->default_engine && !keys %{ $config->passthrough } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$remote_config and not $model_count and not $config->default_engine and not keys %{$config->passthrough;}
$remote_config and not $model_count and not $config->default_engine
$remote_config and not $model_count
MC/DC0%0/4
$remote_config and not $model_count and not $config->default_engine and not keys %{$config->passthrough;}
$remote_config
not $model_count
not $config->default_engine
not keys %{$config->passthrough;}
Truth table0%0/5
A and not(B) and not(C) and not(D)
A= $remote_configB= not $model_countC= not $config->default_engineD= not keys %{$config->passthrough;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | _log("Engines: none yet (remote config: requests answer 503 until PUT /knarr/admin/config)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } elsif ($model_count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | _log("Engines: $model_count provider(s) configured"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | _log(""); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | for my $name (sort keys %$models) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $m = $models->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $line = " $name"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $line .= " => $m->{engine}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $line .= " / $m->{model}" if $m->{model}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ($m->{api_key_env}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $line .= " (key from \$$m->{api_key_env})"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | _log($line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | _log(""); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | _log("Engines: none (passthrough only mode)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ($config->auto_discover && !$token_auth) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$config->auto_discover and not $token_auth
MC/DC0%0/2
$config->auto_discover and not $token_auth
$config->auto_discover
not $token_auth
Truth table0%0/3
A and not(B)
A= $config->auto_discoverB= not $token_auth
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | _log("Auto-discover: enabled (will query provider model lists)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if ($config->default_engine) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | _log("Default engine: $config->{data}{default}{engine}"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # Passthrough status | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $pt = $config->passthrough; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($token_auth) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | _log("Passthrough: off (token_auth)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } elsif (keys %$pt) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my @fmts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | for my $fmt (sort keys %$pt) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | push @fmts, "$fmt -> $pt->{$fmt}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | _log("Passthrough: " . join(', ', @fmts)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | _log("Passthrough: disabled"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # Langfuse tracing status | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my $lf_pub = $config->langfuse->{public_key} // _strip_quotes($ENV{LANGFUSE_PUBLIC_KEY}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$config->langfuse->{"public_key"} // _strip_quotes($ENV{"LANGFUSE_PUBLIC_KEY"})
MC/DC0%0/2
$config->langfuse->{"public_key"} // _strip_quotes($ENV{"LANGFUSE_PUBLIC_KEY"})
$config->langfuse->{"public_key"}
_strip_quotes($ENV{"LANGFUSE_PUBLIC_KEY"})
Truth table0%0/3
A // B
A= $config->langfuse->{"public_key"}B= _strip_quotes($ENV{"LANGFUSE_PUBLIC_KEY"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | my $lf_sec = $config->langfuse->{secret_key} // _strip_quotes($ENV{LANGFUSE_SECRET_KEY}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$config->langfuse->{"secret_key"} // _strip_quotes($ENV{"LANGFUSE_SECRET_KEY"})
MC/DC0%0/2
$config->langfuse->{"secret_key"} // _strip_quotes($ENV{"LANGFUSE_SECRET_KEY"})
$config->langfuse->{"secret_key"}
_strip_quotes($ENV{"LANGFUSE_SECRET_KEY"})
Truth table0%0/3
A // B
A= $config->langfuse->{"secret_key"}B= _strip_quotes($ENV{"LANGFUSE_SECRET_KEY"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my $lf_url = $config->langfuse->{url} // _strip_quotes($ENV{LANGFUSE_URL}) // _strip_quotes($ENV{LANGFUSE_BASE_URL}) // 'https://cloud.langfuse.com'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
(($config->langfuse->{"url"} // _strip_quotes($ENV{"LANGFUSE_URL"})) // _strip_quotes($ENV{"LANGFUSE_BASE_URL"})) // "https://cloud.langfuse.com"
($config->langfuse->{"url"} // _strip_quotes($ENV{"LANGFUSE_URL"})) // _strip_quotes($ENV{"LANGFUSE_BASE_URL"})
$config->langfuse->{"url"} // _strip_quotes($ENV{"LANGFUSE_URL"})
MC/DC0%0/3
(($config->langfuse->{"url"} // _strip_quotes($ENV{"LANGFUSE_URL"})) // _strip_quotes($ENV{"LANGFUSE_BASE_URL"})) // "https://cloud.langfuse.com"
$config->langfuse->{"url"}
_strip_quotes($ENV{"LANGFUSE_URL"})
_strip_quotes($ENV{"LANGFUSE_BASE_URL"})
Truth table0%0/4
A // B // C
A= $config->langfuse->{"url"}B= _strip_quotes($ENV{"LANGFUSE_URL"})C= _strip_quotes($ENV{"LANGFUSE_BASE_URL"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ($lf_pub && $lf_sec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lf_pub and $lf_sec
MC/DC0%0/2
$lf_pub and $lf_sec
$lf_pub
$lf_sec
Truth table0%0/3
A and B
A= $lf_pubB= $lf_sec
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | _log("Langfuse: enabled -> $lf_url (" . $config->langfuse_transport . ")"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | _log("Langfuse: disabled (set LANGFUSE_PUBLIC_KEY + LANGFUSE_SECRET_KEY to enable)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # Proxy auth status | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ($token_auth) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # the Auth line above says it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } elsif ($config->has_proxy_api_key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | _log("Proxy auth: enabled (KNARR_API_KEY)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } elsif (defined $config->proxy_api_key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | _log("WARNING: proxy_api_key / KNARR_API_KEY is empty, proxy is OPEN (no authentication)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | _log("Proxy auth: open (set KNARR_API_KEY to require authentication)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # Admin routes status; never the key itself | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ($admin_on) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | _log("Admin routes: enabled under /knarr/admin/ (admin key set)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | _log("Admin routes: off (set KNARR_ADMIN_KEY to enable)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | _log("Remote config: on (PUT /knarr/admin/config lays a setup over this one, in memory only)") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$remote_config and $admin_on
MC/DC0%0/2
$remote_config and $admin_on
$remote_config
$admin_on
Truth table0%0/3
A and B
A= $remote_configB= $admin_on
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | if $remote_config && $admin_on; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # Request logging status | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $log_file = $config->log_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $log_dir = $config->log_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ($log_file || $log_dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$log_file or $log_dir
MC/DC0%0/2
$log_file or $log_dir
$log_file
$log_dir
Truth table0%0/3
A or B
A= $log_fileB= $log_dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | push @parts, "file: $log_file" if $log_file; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | push @parts, "dir: $log_dir" if $log_dir; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | _log("Logging: " . join(', ', @parts)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | _log("Logging: disabled (set KNARR_LOG_FILE or KNARR_LOG_DIR to enable)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | _log(""); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # Build server | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | require Langertha::Knarr; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | require Langertha::Knarr::Stack; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | require Langertha::Knarr::Tracing; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | require Langertha::Knarr::RequestLog; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | require IO::Async::Loop; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $loop = IO::Async::Loop->new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $tracing = Langertha::Knarr::Tracing->new( config => $config ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $rlog = Langertha::Knarr::RequestLog->new( config => $config ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # Router, passthrough, handler chain and proxy key from the config; an | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # admin push builds the next one the same way (k75). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | my $stack = Langertha::Knarr::Stack->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | config => $config, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | loop => $loop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | tracing => $tracing->_enabled ? $tracing : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | request_log => $rlog->_enabled ? $rlog : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # Builds the token store, which loads DBD::Pg (not connecting: each | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # serving process does that once it serves, never this one before a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # fork): a missing driver stops here, not at the first request. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ($token_auth) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | unless ( eval { $stack->build; 1 } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ( my $err = $@ ) =~ s/ at \S+ line \d+\.?\n?\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | _err($err); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $admin; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | if ($admin_on) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | require Langertha::Knarr::Admin; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $admin = Langertha::Knarr::Admin->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | key => $config->admin_key, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | stack => $stack, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | remote_config => $remote_config, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $passthrough = $stack->raw_passthrough; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | my $knarr = Langertha::Knarr->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | handler => $stack->handler, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | loop => $loop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | listen => $listen_addrs, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | router => $stack->router, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ( $passthrough ? ( raw_passthrough => $passthrough ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | ( $tracing->_enabled ? ( tracing => $tracing ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | ( defined $stack->auth_token ? ( auth_token => $stack->auth_token ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | ( $stack->authorizer ? ( authorizer => $stack->authorizer ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ( $admin ? ( admin => $admin ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | ( defined $config->public_url ? ( public_url => $config->public_url ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ( defined $config->ollama_compat_version | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | ? ( ollama_compat_version => $config->ollama_compat_version ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | protocol_args => $config->protocol_args, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | workers => $workers, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | _log("Starting server:"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | for my $addr (@$listen_addrs) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | _log(" http://$addr"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | _log("Workers: $workers") if $workers > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | _log(""); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $knarr->run; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # The worker count: -w, else the config's workers: / KNARR_WORKERS (k51). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # A bad value stops start here, before the banner and before any bind. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub _workers { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_workers: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my ($self, $config) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if ( $self->has_workers ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | return $self->workers if $self->workers >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | _err("-w/--workers must be 1 or more, got " . $self->workers); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $workers = eval { $config->workers }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | return $workers if defined $workers; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ( my $err = $@ ) =~ s/ at \S+ line \d+\.?\n?\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | _err($err); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | sub _log { print STDERR "[knarr] $_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | ▶ | sub _err { print STDERR "[knarr] ERROR: $_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_err: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub _strip_quotes { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_quotes: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $v = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | return $v unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $v =~ s/^["']|["']$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 39 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||