58 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env perl
 | |
| 
 | |
| use strict;
 | |
| use warnings FATAL => 'all';
 | |
| 
 | |
| our $home;
 | |
| 
 | |
| BEGIN {
 | |
|   # try really hard to find a localenv if one isn't already in place.
 | |
|   $home = ($ENV{NETDISCO_HOME} || $ENV{HOME});
 | |
|   eval "require App::Netdisco::Util::Noop";
 | |
| 
 | |
|   if ($@) {
 | |
|       use File::Spec;
 | |
|       my $localenv = File::Spec->catfile($FindBin::RealBin, 'localenv');
 | |
|       exec($localenv, $0, @ARGV) if -f $localenv;
 | |
|       $localenv = File::Spec->catfile($home, 'perl5', 'bin', 'localenv');
 | |
|       exec($localenv, $0, @ARGV) if -f $localenv;
 | |
|       die "Sorry, can't find libs required for App::Netdisco.\n";
 | |
|   }
 | |
| }
 | |
| 
 | |
| use FindBin;
 | |
| FindBin::again();
 | |
| use Path::Class;
 | |
| use Daemon::Control;
 | |
| 
 | |
| my $netdisco = file($FindBin::RealBin, 'netdisco-daemon-fg');
 | |
| my @args = (scalar @ARGV > 1 ? @ARGV[1 .. $#ARGV] : ());
 | |
| 
 | |
| my $log_dir = dir($home, 'logs');
 | |
| mkdir $log_dir if ! -d $log_dir;
 | |
| 
 | |
| Daemon::Control->new({
 | |
|   name => 'Netdisco Daemon',
 | |
|   program  => $netdisco,
 | |
|   program_args => [@args],
 | |
|   pid_file => file($home, 'netdisco-daemon.pid'),
 | |
|   stderr_file => file($log_dir, 'netdisco-daemon.log'),
 | |
|   stdout_file => file($log_dir, 'netdisco-daemon.log'),
 | |
| })->run;
 | |
| 
 | |
| =head1 NAME
 | |
| 
 | |
| netdisco-daemon - Job Control Daemon for Netdisco
 | |
| 
 | |
| =head1 SEE ALSO
 | |
| 
 | |
| =over 4
 | |
| 
 | |
| =item *
 | |
| 
 | |
| L<App::Netdisco>
 | |
| 
 | |
| =back
 | |
| 
 | |
| =cut
 |