Commit 4f885af1 authored by Leigh Stoller's avatar Leigh Stoller

Start slothd inside openvz containers.

Change the logging code so that we get better output on early failure.
Openvz nodes do not have a "console" so early errors are lost. This is
a real pain, cause before this point, we have no idea what went wrong.
Later versions of openvz are supposed to have a console.
parent 82b9d2fb
......@@ -23,6 +23,7 @@
#
use English;
use Getopt::Std;
use IO::Handle;
#
# This script is run directly from boot. It should NOT be run after
......@@ -112,6 +113,8 @@ if (REMOTE() && $action eq "boot") {
sleep(5);
}
STDOUT->autoflush(1);
STDERR->autoflush(1);
#
# Grab our manifest so we can enable/disable/replace this script and
......@@ -126,9 +129,9 @@ getmanifest(\%manifest);
if ($action eq "boot" || $action eq "reconfig") {
open(LOG, "> $LOGFILE") or
BootFatal(-1, "Could not open $LOGFILE!");
my $ofh = select(LOG);
$| = 1;
select($ofh);
LOG->autoflush(1);
LOG->autoflush(1);
#
# This open implicitly forks a child, which goes on to execute the rest
......@@ -136,8 +139,11 @@ if ($action eq "boot" || $action eq "reconfig") {
# output of the child, writing it to the logfile and to the console.
#
my $pid = open(FOO, "-|");
BootFatal($? >> 8, "Boot Failure; popen failed!")
if (!defined($pid));
if (!defined($pid)) {
print LOG "Boot Failure; popen failed!\n";
close(LOG);
BootFatal($? >> 8, "Boot Failure; popen failed!")
}
if ($pid) {
while (<FOO>) {
......@@ -146,6 +152,9 @@ if ($action eq "boot" || $action eq "reconfig") {
print "$_";
}
}
if ($?) {
print LOG "Boot Failure: $?\n";
}
close(LOG);
close(FOO);
if ($?) {
......@@ -158,10 +167,7 @@ if ($action eq "boot" || $action eq "reconfig") {
# Need this or ssh will hang, even though it was called with -n option.
open(STDIN, "</dev/null");
}
if (REMOTE()) {
# Maybe just do this all the time.
open(STDERR, ">&STDOUT");
}
open(STDERR, ">&STDOUT");
}
# Execute the action.
......@@ -321,8 +327,7 @@ sub doboot()
runbootscript(\%manifest,$RCDIR,'rc.healthd','boot','start');
}
if (-x "$RCDIR/rc.slothd" &&
!(REMOTE() || (GENVNODE() && !INXENVM()))) {
if (-x "$RCDIR/rc.slothd" && !REMOTE()) {
print("Starting slothd usage detector\n");
runbootscript(\%manifest,$RCDIR,'rc.slothd','boot','start');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment