1 |
eval 'exec /home/jsoc/bin/$JSOC_MACHINE/perl -S $0 "$@"' |
2 |
if 0; |
3 |
#/home/jim/cvs/JSOC/proj/lev0/scripts/start_ingest_lev0_hmi |
4 |
#This is to start the ingest_lev0 for 2 VCs for HMI. |
5 |
# |
6 |
$| = 1; #flush output as we go |
7 |
$DB = "jsoc"; #the "real" db that production uses |
8 |
#$DB = "jsocdc"; #the "real" db that production uses |
9 |
#$GREPPS = "388"; #grep for this in ps -ef |
10 |
$GREPPS = "jim"; |
11 |
$HOST = "d00.Stanford.EDU"; #where sum_svc runs |
12 |
|
13 |
$user = $ENV{'USER'}; |
14 |
if($user ne "production") { |
15 |
print "You must be user production to run\n"; |
16 |
print "!!!TEMP allow...\n"; |
17 |
#exit; |
18 |
} |
19 |
$host = `hostname`; |
20 |
chomp($host); |
21 |
if($host ne $HOST) { |
22 |
print "This can only be run on $HOST.\n"; |
23 |
exit; |
24 |
} |
25 |
|
26 |
$PID = getppid; |
27 |
$LOGFILE = "/tmp/start_ingest_lev0_hmi.$PID"; |
28 |
$MLOGFILE = "/tmp/start_ingest_lev0_mail_hmi.$PID"; |
29 |
open(LOG, ">$LOGFILE") || die "Can't open $LOGFILE: $!\n"; |
30 |
open(MLOG, ">$MLOGFILE") || die "Can't open $MLOGFILE: $!\n"; |
31 |
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); |
32 |
$sec2 = sprintf("%02d", $sec); |
33 |
$min2 = sprintf("%02d", $min); |
34 |
$hour2 = sprintf("%02d", $hour); |
35 |
$mday2 = sprintf("%02d", $mday); |
36 |
$mon2 = sprintf("%02d", $mon+1); |
37 |
$year2 = sprintf("%02d", $year); |
38 |
$date = (1900 + $year).".".$mon2.".$mday2"._.$hour2.":$min2".":$sec2"; |
39 |
print "start_ingest_lev0_hmi at $date\n\n"; |
40 |
print LOG "start_ingest_lev0_hmi at $date\n\n"; |
41 |
print MLOG "start_ingest_lev0_hmi at $date\n"; |
42 |
print MLOG "See $LOGFILE for more details\n"; |
43 |
|
44 |
@ps_prod = `ps -ef | grep $GREPPS`; |
45 |
#print "The ps -ef for producttion is:\n@ps_prod\n"; |
46 |
print LOG "The ps -ef for product is:\n@ps_prod\n"; |
47 |
@process = (); |
48 |
@psid = (); |
49 |
$process = ""; |
50 |
while($_ = shift(@ps_prod)) { |
51 |
if(/^$GREPPS/) { #do for all production processes |
52 |
if(/start_ingest_lev0_hmi/) { #don't kill ourselves |
53 |
next; |
54 |
} |
55 |
if(/ingest_lev0 -pVC02/) { |
56 |
($a, $psid, $c) = split(/\s+/, $_); |
57 |
push(@psid, $psid); |
58 |
$process = "ingest_lev0 -pVC02"; |
59 |
push(@process, $process); |
60 |
} |
61 |
elsif(/ingest_lev0 -pVC05/) { |
62 |
($a, $psid, $c) = split(/\s+/, $_); |
63 |
push(@psid, $psid); |
64 |
$process = "ingest_lev0 -pVC05"; |
65 |
push(@process, $process); |
66 |
} |
67 |
#elsif(/ingest_lev0 -pVC01/) { |
68 |
# ($a, $psid, $c) = split(/\s+/, $_); |
69 |
# push(@psid, $psid); |
70 |
# $process = "ingest_lev0 -pVC01"; |
71 |
# push(@process, $process); |
72 |
#} |
73 |
#elsif(/ingest_lev0 -pVC04/) { |
74 |
# ($a, $psid, $c) = split(/\s+/, $_); |
75 |
# push(@psid, $psid); |
76 |
# $process = "ingest_lev0 -pVC04"; |
77 |
# push(@process, $process); |
78 |
#} |
79 |
else { |
80 |
next; |
81 |
} |
82 |
print "** NOTE: \"$process\" still running\n"; |
83 |
print LOG "** NOTE: \"$process\" still running\n"; |
84 |
} |
85 |
} |
86 |
if($process ne "") { |
87 |
print "Do you want me to kill and restart these processes (y or n):\n"; |
88 |
while(<STDIN>) { |
89 |
chop($_); |
90 |
if(($_ eq "Y") || ($_ eq "y")) { |
91 |
while($x = shift(@process)) { |
92 |
$pid = shift(@psid); |
93 |
$cmd = "kill -9 $pid"; |
94 |
print "Killing $x: $cmd\n"; |
95 |
`$cmd`; |
96 |
} |
97 |
} |
98 |
else { |
99 |
print "Aborting start_ingest_lev0_hmi\n"; |
100 |
exit; |
101 |
} |
102 |
} |
103 |
} |
104 |
print "** Now starting ingest_lev0_hmi processes\n"; |
105 |
print LOG "** Now starting ingest_lev0_hmi processes\n"; |
106 |
$cmd = "ingest_lev0 -pVC02 /dds/socdc/hmi /dds/pipe2pipe/hmi /usr/local/logs/soc/ingest_lev0_VC02.$PID &"; |
107 |
print "$cmd\n"; |
108 |
if(system($cmd)) { |
109 |
print "Error: failure on cmd\n"; |
110 |
} |
111 |
print "start_ingest_lev0_hmi Complete\n"; |
112 |
print LOG "start_ingest_lev0_hmi Complete\n"; |
113 |
close(LOG); |
114 |
close(MLOG); |
115 |
$mail = "Mail -s \"start_ingest_lev0_hmi Complete\""; |
116 |
#$to = "sssc_crew\@solar2"; |
117 |
$to = "jim"; |
118 |
$cmd = "$mail $to < $MLOGFILE"; |
119 |
system $cmd; |
120 |
exit; |
121 |
|