#!/usr/bin/perl

# ------------------------------------------------------------------------
# stoparch -- Stop the hotarch (see hotarch.pl)

# Set the common parameters (contained in common.pl)
use File::Basename;
$MyPath = dirname($0);
require "$MyPath\\common.pl";

# ------------------------------------------------------------------------

# Main ... start here:
$MyName = basename $0,"\.pl";
die "usage: $MyName db_name\n" unless (@ARGV == 1);
$orasid = $ARGV[0];
$lockfile = "$logdir\\hotarch.$orasid.lock";
$stopfile = "$logdir\\hotarch.$orasid.stop";
die "\nhotarch is not running!\n\n" unless (-f $lockfile);
die "\nThere is a Stop Request Already Pending!\n\n" if (-f $stopfile);
open(STOP,">>$stopfile") || die "error opening $stopfile\n";
print STOP "hotarch stop request pending\n";
close(STOP) || die "$!";
print "Stop request pending ";
while (-f $lockfile){
	sleep 20;
	print ".";
}
print "\n$orasid hotarch Stopped!\n\n";
