forked from ytoolshed/pogo
/
loadconf.pl
executable file
·101 lines (69 loc) · 2.22 KB
/
loadconf.pl
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
#!/usr/bin/env perl -w
# Copyright (c) 2010-2011 Yahoo! Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
use common::sense;
use FindBin qw($Bin);
use lib "$Bin/../lib";
use Pogo::Engine;
use Log::Log4perl qw(:easy);
use YAML::XS qw(LoadFile);
use LWP::UserAgent;
# it's sorta lame to set up log4perl here, but inside the Engine stuff it's
# used extensively
Log::Log4perl::init(
\q{
log4perl.rootLogger = DEBUG, screen
log4perl.appender.screen = Log::Log4perl::Appender::Screen
log4perl.appender.screen.stderr = 0
log4perl.appender.screen.syswrite = 0
log4perl.appender.screen.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.screen.layout.ConversionPattern = [%P] %p %F{2}:%L %m%n
}
);
if ( @ARGV < 3 )
{
LOGDIE "usage: $0 <config> <namespace> <constraint.yaml>\n";
}
my $configf = shift @ARGV;
my $namespace = shift @ARGV;
my $constraintsf = shift @ARGV;
my $config = LoadFile($configf) || LOGDIE "cannot load $configf";
my $constraints = LoadFile($constraintsf) || LOGDIE "cannot load $constraintsf";
my $ns = Pogo::Engine->init($config)->namespace($namespace)->init->set_conf($constraints);
1;
=pod
=head1 NAME
CLASSNAME - SHORT DESCRIPTION
=head1 SYNOPSIS
CODE GOES HERE
=head1 DESCRIPTION
LONG_DESCRIPTION
=head1 METHODS
B<methodexample>
=over 2
methoddescription
=back
=head1 SEE ALSO
L<Pogo::Dispatcher>
=head1 COPYRIGHT
Apache 2.0
=head1 AUTHORS
Andrew Sloane <andy@a1k0n.net>
Michael Fischer <michael+pogo@dynamine.net>
Mike Schilli <m@perlmeister.com>
Nicholas Harteau <nrh@hep.cat>
Nick Purvis <nep@noisetu.be>
Robert Phan <robert.phan@gmail.com>
=cut
# vim:syn=perl:sw=2:ts=2:sts=2:et:fdm=marker