properly daemonize spectre
This commit is contained in:
parent
8129bef2fb
commit
fc524df15c
1 changed files with 15 additions and 7 deletions
|
|
@ -70,7 +70,8 @@ STOP
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $config = WebGUI::Config->new("..","spectre.conf",1);
|
require File::Spec;
|
||||||
|
my $config = WebGUI::Config->new(File::Spec->rel2abs(".."),"spectre.conf",1);
|
||||||
unless (defined $config) {
|
unless (defined $config) {
|
||||||
print <<STOP;
|
print <<STOP;
|
||||||
|
|
||||||
|
|
@ -106,12 +107,19 @@ if ($shutdown) {
|
||||||
} elsif ($run) {
|
} elsif ($run) {
|
||||||
Spectre::Admin->new($config, $debug);
|
Spectre::Admin->new($config, $debug);
|
||||||
} elsif ($daemon) {
|
} elsif ($daemon) {
|
||||||
my $res = ping();
|
if (!ping()) {
|
||||||
print "Spectre is already running.\n" unless $res;
|
die "Spectre is already running.\n";
|
||||||
exit unless $res;
|
}
|
||||||
#fork and exit(sleep(1) and print((ping())?"Spectre failed to start!\n":"Spectre started successfully!\n")); #Can't have right now.
|
#fork and exit(sleep(1) and print((ping())?"Spectre failed to start!\n":"Spectre started successfully!\n")); #Can't have right now.
|
||||||
fork and exit;
|
require POSIX;
|
||||||
Spectre::Admin->new($config, $debug);
|
fork and exit;
|
||||||
|
POSIX::setsid();
|
||||||
|
chdir "/";
|
||||||
|
open STDIN, "+>", File::Spec->devnull;
|
||||||
|
open STDOUT, "+>STDIN";
|
||||||
|
open STDERR, "+>STDIN";
|
||||||
|
fork and exit;
|
||||||
|
Spectre::Admin->new($config, $debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ping {
|
sub ping {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue