Files
netdisco/Netdisco/bin/netdisco-daemon-fg
Oliver Gorwits 04d89320a8 Squashed commit of the following:
* Support for stuffing other locations into @INC at runtime
* Reports config is now a list (see ReleaseNotes)

commit 19756faf57
Merge: 2e8afbe 29d3ac7
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Thu Jul 31 21:32:30 2014 +0100

    Merge branch 'master' into og-autoload

    Conflicts:
    	Netdisco/share/public/javascripts/netdisco_portcontrol.js

commit 2e8afbeea6
Merge: d340c3b 18f507e
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed Jul 23 20:09:18 2014 +0100

    Merge branch 'master' into og-autoload

commit d340c3b135
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jul 7 22:25:38 2014 +0100

    tweak dirty css

commit 032cd82c46
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jul 6 23:05:17 2014 +0100

    add dirty classes

commit 2b72c989fa
Merge: 1b8ac7c b77025f
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Fri Jul 4 11:28:01 2014 +0100

    Merge branch 'og-autoload' of ssh://git.code.sf.net/p/netdisco/netdisco-ng into og-autoload

commit b77025f34c
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Thu Jul 3 23:35:35 2014 +0100

    hide save icon

commit 5df5a73aed
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed Jul 2 22:31:18 2014 +0100

    blue color

commit a3bf20f074
Merge: 1839f26 db53c00
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed Jul 2 15:17:25 2014 +0100

    Merge branch 'master' into og-autoload

commit 1b8ac7ca1f
Merge: 1839f26 db53c00
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed Jul 2 09:23:31 2014 +0100

    Merge branch 'master' into og-autoload

commit 1839f2634b
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed Jul 2 03:43:53 2014 +0100

    add jquery.fix.clone.js

commit 3eee9f1997
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed Jul 2 00:08:27 2014 +0100

    save button css

commit 95b6cb61b3
Merge: 13957e8 58e5d05
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Tue Jul 1 21:50:01 2014 +0100

    Merge branch 'master' into og-autoload

    Conflicts:
    	Netdisco/share/config.yml

commit 13957e82dc
Merge: bedbec6 6abceba
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jun 30 22:50:40 2014 +0100

    Merge branch 'og-autoload' of ssh://git.code.sf.net/p/netdisco/netdisco-ng into og-autoload

commit bedbec6b4b
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jun 30 22:49:49 2014 +0100

    css fixes

commit 6e2d5a4b48
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jun 30 21:30:26 2014 +0100

    css fixes

commit 755fc92c59
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jun 30 13:05:43 2014 +0100

    reports now a list not a hash

commit 6abcebafbe
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jun 29 12:41:47 2014 +0100

    start as non-root if port switch not required

commit e5e0c0c8d1
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sat Jun 28 13:10:51 2014 +0100

    fix err in docs

commit 6d680aabed
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sat Jun 28 11:10:23 2014 +0100

    move content

commit d2668d6db7
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Fri Jun 27 00:30:54 2014 +0100

    minor styling

commit e46cbd252d
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Thu Jun 26 23:19:19 2014 +0100

    add bootstrap-switch checkbox styling

commit 5b0a723c9f
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed Jun 25 22:20:57 2014 +0100

    typo in defaults

commit e45fa89c44
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Tue Jun 24 22:42:45 2014 +0100

    css for configuration pane

commit 62c53a5e49
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jun 23 23:33:26 2014 +0100

    minor typo

commit caedbdadc6
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jun 23 20:35:30 2014 +0100

    properly search the template path!! [#103]

commit 5742bc7856
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jun 22 23:13:53 2014 +0100

    fix registering template paths

commit 2b09476f29
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jun 22 22:19:35 2014 +0100

    allow INC stuffing via NETDISCO_INC env var

commit 7c47a277be
Merge: 128e96f 3a1cd19
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jun 22 22:17:11 2014 +0100

    Merge branch 'master' into og-autoload

commit 128e96f9a3
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jun 22 20:48:01 2014 +0100

    use Module::Find to load Auto things and Web
2014-07-31 22:54:28 +01:00

126 lines
2.8 KiB
Perl
Executable File

#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
FindBin::again();
use Path::Class 'dir';
BEGIN {
# stuff useful locations into @INC
unshift @INC,
dir($FindBin::RealBin)->parent->subdir('lib')->stringify,
dir($FindBin::RealBin, 'lib')->stringify;
unshift @INC,
split m/:/, ($ENV{NETDISCO_INC} || '');
}
use App::Netdisco;
use Dancer qw/:moose :script/;
warning sprintf "App::Netdisco %s backend", ($App::Netdisco::VERSION || 'HEAD');
# local job queue management
use App::Netdisco::Daemon::LocalQueue ':all';
# needed to quench AF_INET6 symbol errors
use NetAddr::IP::Lite ':lower';
use List::Util 'sum';
use Role::Tiny::With;
use MCE::Signal '-setpgrp';
use MCE;
# set temporary MCE files' location in home directory
my $home = ($ENV{NETDISCO_HOME} || $ENV{HOME});
my $tmp_dir = ($ENV{NETDISCO_TEMP} || dir($home, 'tmp'));
mkdir $tmp_dir if ! -d $tmp_dir;
my $mce = MCE->new(
spawn_delay => 0.15,
job_delay => 1.15,
tmp_dir => $tmp_dir,
user_func => sub { $_[0]->worker_body },
on_post_exit => \&restart_this_worker,
user_tasks => build_tasks_list(),
)->run();
sub build_tasks_list {
# NB MCE does not like max_workers => 0
my $tasks = [];
push @$tasks, {
max_workers => 1,
user_begin => worker_factory('Manager'),
} if num_workers() > 0;
push @$tasks, {
max_workers => 1,
user_begin => worker_factory('Scheduler'),
} if setting('schedule');
my @logmsg = ();
foreach my $key (keys %{setting('job_type_keys')}) {
my $val = setting('job_type_keys')->{$key};
setting('workers')->{$val} = 2
if !defined setting('workers')->{$val};
push @logmsg, setting('workers')->{$val} ." $key";
push @$tasks, {
max_workers => setting('workers')->{$val},
user_begin => worker_factory($key),
} if setting('workers')->{$val};
}
info sprintf "MCE will load: %s Manager, %s Scheduler, %s",
(num_workers() ? 1 : 0),
(setting('schedule') ? 1 : 0),
(join ', ', @logmsg);
return $tasks;
}
sub num_workers {
return sum( 0, map { setting('workers')->{$_} }
values %{setting('job_type_keys')} );
}
sub worker_factory {
my $role = shift;
return sub {
my $self = shift;
my $wid = $self->wid;
info "applying role $role to worker $wid";
# $self->sendto('stderr', ">>> worker $wid starting with role $role\n");
Role::Tiny->apply_roles_to_object($self, "App::Netdisco::Daemon::Worker::$role");
$self->worker_begin if $self->can('worker_begin');
};
}
sub restart_this_worker {
my ($self, $e) = @_;
reset_jobs($e->{wid});
debug "restarting worker $e->{wid}";
$self->restart_worker($e->{wid});
}
=head1 NAME
netdisco-daemon-fg - Job Control for Netdisco
=head1 SEE ALSO
=over 4
=item *
L<App::Netdisco>
=back
=cut