* Support for stuffing other locations into @INC at runtime * Reports config is now a list (see ReleaseNotes) commit19756faf57Merge:2e8afbe29d3ac7Author: 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 commit2e8afbeea6Merge:d340c3b18f507eAuthor: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 23 20:09:18 2014 +0100 Merge branch 'master' into og-autoload commitd340c3b135Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jul 7 22:25:38 2014 +0100 tweak dirty css commit032cd82c46Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jul 6 23:05:17 2014 +0100 add dirty classes commit2b72c989faMerge:1b8ac7cb77025fAuthor: 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 commitb77025f34cAuthor: Oliver Gorwits <oliver@cpan.org> Date: Thu Jul 3 23:35:35 2014 +0100 hide save icon commit5df5a73aedAuthor: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 2 22:31:18 2014 +0100 blue color commita3bf20f074Merge:1839f26db53c00Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 2 15:17:25 2014 +0100 Merge branch 'master' into og-autoload commit1b8ac7ca1fMerge:1839f26db53c00Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 2 09:23:31 2014 +0100 Merge branch 'master' into og-autoload commit1839f2634bAuthor: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 2 03:43:53 2014 +0100 add jquery.fix.clone.js commit3eee9f1997Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 2 00:08:27 2014 +0100 save button css commit95b6cb61b3Merge:13957e858e5d05Author: 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 commit13957e82dcMerge:bedbec66abcebaAuthor: 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 commitbedbec6b4bAuthor: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 30 22:49:49 2014 +0100 css fixes commit6e2d5a4b48Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 30 21:30:26 2014 +0100 css fixes commit755fc92c59Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 30 13:05:43 2014 +0100 reports now a list not a hash commit6abcebafbeAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 29 12:41:47 2014 +0100 start as non-root if port switch not required commite5e0c0c8d1Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 28 13:10:51 2014 +0100 fix err in docs commit6d680aabedAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 28 11:10:23 2014 +0100 move content commitd2668d6db7Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Jun 27 00:30:54 2014 +0100 minor styling commite46cbd252dAuthor: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 26 23:19:19 2014 +0100 add bootstrap-switch checkbox styling commit5b0a723c9fAuthor: Oliver Gorwits <oliver@cpan.org> Date: Wed Jun 25 22:20:57 2014 +0100 typo in defaults commite45fa89c44Author: Oliver Gorwits <oliver@cpan.org> Date: Tue Jun 24 22:42:45 2014 +0100 css for configuration pane commit62c53a5e49Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 23 23:33:26 2014 +0100 minor typo commitcaedbdadc6Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 23 20:35:30 2014 +0100 properly search the template path!! [#103] commit5742bc7856Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 22 23:13:53 2014 +0100 fix registering template paths commit2b09476f29Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 22 22:19:35 2014 +0100 allow INC stuffing via NETDISCO_INC env var commit7c47a277beMerge:128e96f3a1cd19Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 22 22:17:11 2014 +0100 Merge branch 'master' into og-autoload commit128e96f9a3Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 22 20:48:01 2014 +0100 use Module::Find to load Auto things and Web
		
			
				
	
	
		
			126 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			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
 |