Shell script:
Usage: source startSISPI
#!/bin/tcsh
# Usage: source startSISPI
if ($1 != "") then
set customer = $1
else
set customer = $user
endif
echo "Configuring Pyro Name Server and SVE for user " $customer
setenv PYRO_USER $customer
setenv PYRO_DNS_URI 1
# Overwrite Port numbers?
if ($2 != "" && $3 != "") then
setenv PYRO_PORT $2
setenv PYRO_NS_PORT $3
setenv PYRO_NS_BC_PORT $3
else if ($customer == "eiting") then
setenv PYRO_PORT 8000
setenv PYRO_NS_PORT 8111
setenv PYRO_NS_BC_PORT 8111
else if ($customer == "kkuehn") then
setenv PYRO_PORT 8200
setenv PYRO_NS_PORT 8333
setenv PYRO_NS_BC_PORT 8333
else if ($customer == "richman") then
setenv PYRO_PORT 8400
setenv PYRO_NS_PORT 8444
setenv PYRO_NS_BC_PORT 8444
else if ($customer == "klaus") then
setenv PYRO_PORT 7888
setenv PYRO_NS_PORT 7999
setenv PYRO_NS_BC_PORT 7999
else
echo "Using Default "
setenv PYRO_PORT 7766
setenv PYRO_NS_PORT 9090
setenv PYRO_NS_BC_PORT 9090
endif
echo "PYRO Port Numbers. PYRO_PORT = " $PYRO_PORT ", PYRO_NS_PORT = " $PYRO_NS_PORT, "PYRO_NS_BC_PORT = " $PYRO_NS_BC_PORT
# Reuse old uri file to set PYRO_NS_HOSTNAME
setenv PYRO_NS_HOSTNAME `~/.pyroNS.py`
echo "Trying to find Name Server at " $PYRO_NS_HOSTNAME
# Start Name Server and SVE if necessary
~/.pyroTest.py
# Setting new PYRO_NS_HOSTNAME
setenv PYRO_NS_HOSTNAME `~/.pyroNS.py`
echo "PYRO_NS_HOSTNAME set to " $PYRO_NS_HOSTNAME
For example: source startSISPI klaus 5000 5200
Default values are set for the OSU developers (klaus, eiting, kkuehn, richman)
This script calls the following two python scripts to check if the name server and the SVE are already running.
.pyroTest.py:
#!/usr/bin/env python
import Pyro.core
import Pyro.naming
from Pyro.errors import NamingError
from SVE.PythonClient.SVEclient import *
import os, time
hostname = os.getenv("HOSTNAME")
user = os.getenv("PYRO_USER")
try:
ns=Pyro.naming.NameServerLocator().getNS()
print "PYRO Name Server is running. "
try:
mySVE = Pyro.core.getProxyForURI("PYRONAME://SVE")
print "SVE is running."
except:
print "Starting SVE using default installation"
os.system('xterm -T SVE_%s_%s -iconic -e "/n/cima02/python/installed/SVE/SVE/SVEserver.py" &' % (hostname, user))
except:
print "PYRO Name Server not found. Starting it now."
os.system('xterm -T PYRO_%s_%s -iconic -e "pyro-ns" &' % (hostname, user))
time.sleep(1)
print "Starting SVE using default installation"
os.system('xterm -T SVE_%s_%s -iconic -e "/n/cima02/python/installed/SVE/SVE/SVEserver.py" &' % (hostname, user))
and .pyroNS.py:
#!/usr/bin/env python
# Get location of Pyro Name Server until we fix broadcast.
try:
uri = open('Pyro_NS_URI','r').read()
host = uri.split(":")
hostname = host[1].strip("/")
print hostname
except:
print "UNDEFINED"
No comments:
Post a Comment