File: worker

package info (click to toggle)
openqa 5.1764349525.ffb594867-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,264 kB
  • sloc: perl: 57,599; sql: 26,462; javascript: 8,466; xml: 2,229; sh: 1,705; makefile: 443; python: 249
file content (118 lines) | stat: -rwxr-xr-x 2,438 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env perl
# Copyright 2015-2021 SUSE LLC
# SPDX-License-Identifier: GPL-2.0-or-later

=head1 worker

worker - openQA worker daemon

=head1 SYNOPSIS

worker [OPTIONS]

=head1 OPTIONS

=over 4

=item B<--host> HOST

specify dispatcher/scheduler host to connect to

=item B<--instance> NR

specify instance number, ie pool directory to use

=item B<--apikey> <value>

specify the public key needed for API authentication

=item B<--apisecret> <value>

specify the secret key needed for API authentication

=item B<--isotovideo> PATH

path to isotovideo script, useful for running from git

=item B<--no-cleanup>

don't clean pool directory after job

=item B<--verbose>

verbose output

=item B<--help, -h>

print help

=back

=head1 DESCRIPTION

(no content)

=head1 CONFIG FILE

L<worker> relies on credentials provided by L<OpenQA::Client>, i.e. tries to
find a config file C<client.conf> resolving C<$OPENQA_CONFIG> or
C<~/.config/openqa> or C</etc/openqa/> in this order of preference.
Additionally L<worker> uses a config file C<workers.ini> to configure worker
settings.

Example:
  [global]
  BACKEND = qemu
  HOST = http://openqa.example.com


=head1 SEE ALSO
L<OpenQA::Client>

=cut

BEGIN {
    $ENV{MOJO_MAX_MESSAGE_SIZE} = 0;    # no limit for uploads
    $ENV{MOJO_INACTIVITY_TIMEOUT} = 300;
    $ENV{MOJO_CONNECT_TIMEOUT} = 300;
    # the default is EV, and this heavily screws with our children handling
    $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
    #$ENV{MOJO_LOG_LEVEL} = 'debug';
    #$ENV{MOJO_USERAGENT_DEBUG} = 1;
    #$ENV{MOJO_IOLOOP_DEBUG} = 1;
}

use Mojo::Base -strict, -signatures;
use FindBin;
use lib "$FindBin::RealBin/../lib";
use Carp::Always;
use Getopt::Long;
Getopt::Long::Configure("no_ignore_case");

use OpenQA::Worker;
use OpenQA::Log 'log_info';

my %options;

sub usage ($r) { require Pod::Usage; Pod::Usage::pod2usage($r) }

GetOptions(
    \%options, "no-cleanup", "instance=i", "isotovideo=s", "host=s", "apikey:s",
    "apisecret:s", "verbose|v|debug|d", "help|h",
) or usage(1);

usage(0) if ($options{help});

# count workers from 1 if not set - if tap devices are used worker would try to use tap -1
$options{instance} ||= 1;

my $worker = OpenQA::Worker->new(\%options);
$worker->log_setup_info();

sub catch_exit { $worker->handle_signal(@_) }    # uncoverable statement
$SIG{HUP} = \*catch_exit;
$SIG{TERM} = \*catch_exit;
$SIG{INT} = \*catch_exit;

exit $worker->exec();