Fix --install. Support output=append:FILE.

This commit is contained in:
Daniel Nichter
2013-06-16 15:03:05 -07:00
parent 9c559df77e
commit 459696d4f9

View File

@@ -6996,6 +6996,7 @@ sub run_service {
my $task_output_file = "$tmp_dir/$prefix."
. $service->name
. ".output.$taskno";
my $append = 0;
my $output_file;
my $join_char;
my ($store_key, $store_key_value_tuple);
@@ -7031,6 +7032,10 @@ sub run_service {
$store_key = $taskno;
$output_file = $task_output_file;
}
elsif ( $output =~ m/append:(\S+)/ ) {
$output_file = $1;
$append = 1;
}
if ( !$output_file ) {
$output_file = '/dev/null';
@@ -7106,7 +7111,7 @@ sub run_service {
# special vars like __RUN_N_OUTPUT__, __TMPDIR__, etc.
my $cmd = join(' ',
$task->program,
'>',
($append ? '>>' : '>'),
$output_file,
);
$cmd = replace_special_vars(
@@ -8219,7 +8224,6 @@ sub install {
$step_result = undef;
}
print "$result\n" if $stepno && !$repeat;
return if $done;
while ( $skip ) {
printf $step_fmt,
$stepno + ($repeat ? 0 : 1),
@@ -8229,6 +8233,10 @@ sub install {
print "SKIP\n";
$skip--;
}
if ( $done ) {
print "INSTALLATION COMPLETE\n";
return;
}
# This step
printf $step_fmt,
$stepno + ($repeat ? 0 : 1),
@@ -8257,17 +8265,9 @@ sub install {
if ( !$crontab ) {
die "cron is not installed, or crontab is not in your PATH.\n";
}
$next_step->();
# Must have a valid API key.
my $api_key = $o->get('api-key');
my $client;
my $entry_links;
if ( $flags->{offline} ) {
$skip++;
}
else {
$next_step->();
if ( !$api_key ) {
print "\n";
if ( $interactive || -t STDIN ) {
@@ -8286,6 +8286,13 @@ sub install {
die "Please specify your --api-key.\n";
}
}
my $client;
my $entry_links;
if ( $flags->{offline} ) {
$skip++;
}
else {
$next_step->();
eval {
($client, $entry_links) = get_api_client(
api_key => $api_key,
@@ -8428,14 +8435,20 @@ sub install {
# ########################################################################
$next_step->(done => 1);
if ( $flags->{offline} ) {
}
else {
my $hostname = `hostname`;
chomp($hostname);
print "\nThe agent has been installed and started, but it is not running any services yet. "
. "Go to https://cloud.percona.com/agents#$hostname to enable services for this agent.\n\n";
if ( $flags->{offline} ) {
print "The agent has been installed, but it was not started. "
. "Run pt-agent --daemonize to start the agent, then go to "
. "https://cloud.percona.com/agents#$hostname to enable services "
. "for the agent.\n";
}
else {
print "The agent has been installed and started, but it is not "
. "running any services yet. Go to "
. "https://cloud.percona.com/agents#$hostname to enable services"
. "for the agent.\n";
}
return;
@@ -8451,7 +8464,7 @@ sub create_mysql_user {
$cxn->dbh->do($sql);
};
if ( $EVAL_ERROR ) {
die "Sorry, an error occurred while creating a MySQL user for pt-agent: "
die "Sorry, an error occurred while creating a MySQL user for the agent: "
. $EVAL_ERROR;
}
$cxn->dbh->disconnect();