source: nanoscale/tags/1.0.2/monitor.tcl @ 6716

Last change on this file since 6716 was 3177, checked in by mmc, 10 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 1.4 KB
Line 
1# ----------------------------------------------------------------------
2#  MONITOR
3#
4#  This script checks to see if the nanoscale server is alive, and
5#  if not, it attempts to execute another one.  It is run every so
6#  often to make sure that the system is up and running.
7# ======================================================================
8#  AUTHOR:  Michael McLennan, Purdue University
9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
10#
11#  See the file "license.terms" for information on usage and
12#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13# ======================================================================
14
15# This is where the production nanoscale server should be running
16set port 4000
17
18proc email {to subject body} {
19    set message "To: $to"
20    append message "\nFrom: support@nanohub.org"
21    append message "\nSubject: $subject"
22    append message "\n\n"  ;# sendmail terminates header with blank line
23    append message "$body"
24   
25    catch {
26        set fid [open "| /usr/lib/sendmail -oi -t" "w"]
27        puts -nonewline $fid $message
28        close $fid
29    }
30}
31
32if {[catch {socket localhost $port}]} {
33    if {[catch {exec /bin/sh /opt/nanovis/bin/start_server &} err]} {
34        email mmc@tmail.com "nanoVIS problem" "Can't launch server on [info hostname]:\n$err"
35    } else {
36        email mmc@tmail.com "nanoVIS restarted" "Relaunched server on [info hostname] at [clock format [clock seconds]]"
37    }
38}
Note: See TracBrowser for help on using the repository browser.