-í
•šˆOc       sè     d  k  Z   d  k Z  d  k Z  d  k Z  d  k Z  d  k Z 	 d  k Z 
 d  k Z  e i	 Z	  d Z
  d Z  d Z  d Z  d Z ! d Z " d Z # d Z & d Z ' d Z ) d g Z * d	 d
 e e f g Z + d d
 e e f g Z , e d g Z - d d d d e e f g Z 6 d „  Z P d „  Z ] d „  Z a e d „ Z e d „  Z n d „  Z r d „  Z v e e  e  d „ Z! € e e  e  d „ Z" ‹ e  d „ Z# ’ d „  Z$ — d „  Z% › d „  Z&   d „  Z' § d e( f d  „  ƒ  YZ) ® d! „  Z* ³ d" „  Z+ ¹ d# „  Z, Ã d$ „  Z- d% „  Z. Fd& „  Z/ Qd' „  Z0 Wd( „  Z1 od) „  Z2 «e	 i3 d* ƒ ¬e	 i4 e	 i5 ƒ ®e6 e i7 ƒ d+ j  o ¯e ƒ  °e i8 d ƒ n ²y ³e  i9 d, Z: Wn* ´µe	 i; d- ƒ ¶e i8 d. ƒ n X¸y ¹e  i9 d/ Z< Wn* º»e	 i; d0 ƒ ¼e i8 d. ƒ n Xâe= e i7 d ƒ ãyì äe6 e> ƒ d j o$ åe	 i; d1 ƒ æe i8 d. ƒ n çe6 e? ƒ d j o$ èe	 i; d2 ƒ ée i8 d. ƒ n êe6 e@ ƒ d j o$ ëe	 i; d3 ƒ ìe i8 d. ƒ n íe6 eA ƒ d j o$ îe	 i; d4 ƒ ïe i8 d. ƒ n WnB ðeB j
 o3 ZC ñe	 i; d5 eC iD ƒ  ƒ òe i8 d. ƒ n Xôh  ZE õe? d+ f e@ d+ f eA d+ f g ZF ÷e i7 d d6 j o øe- e? ƒ në úe i7 d d7 j o ûe- e@ ƒ nÃ ýe i7 d d8 j o þe- eA ƒ n›  e i7 d d9 j o e/ d ƒ ns e i7 d d: j o e0 ƒ  nN e i7 d d; j o e2 eF ƒ n& 
e	 i; d< e i7 d ƒ e ƒ  d  S(=   Ni    i   iöÿÿÿi
   i   s	   localhosti   s   SystemEventChannels   -ORBIIOPAddrs
   inet:%s:%us   -ORBNamingAddrs   -ORBIIOPBlockings   -ORBids   omniORB3s   -ORBInitRefs   NameService=corbaname::%s:%uc     s>   6 7 d t  i d }  L t i |  ƒ M t  i i |  ƒ d  S(   Ns¨  
Usage: %s <config file> <command>

Where command is one of:

    start - Starts all the required processes and exits.

    startdata - Starts the data related processes and exits.

    startsafemode - Starts the data related processes in safemode and exits.

    stop -  Stops all the processes.

    status - Display status for the processes.

    spawn - Start all the required processes and then monitor them.
        When a required process dies, restart all of the processes.
        Restart all processes on receipt of a SIGUSR1 signal.
        Stop all processes and reboot on receipt of a SIGUSR2 signal.
        Stop all processes on receipt of other catchable signals.
i    (   s   syss   argvs   ss   Logs   infos   stderrs   write(   s   s(    (    s	   istard.pys   usage6 s   c    s“   P Q t  i |  ƒ o R d t  i |  ƒ Snb S t  i |  ƒ o T d t  i |  ƒ Sn7 U t  i |  ƒ o V d t  i |  ƒ Sn X d |  Sd  S(   Ns   exited with status %ds   exited on signal %ds   stopped on signal %ds   returned unknown status %d(   s   oss	   WIFEXITEDs   statuss   WEXITSTATUSs   WIFSIGNALEDs   WTERMSIGs
   WIFSTOPPEDs   WSTOPSIG(   s   status(    (    s	   istard.pys   exitDescriptionP s   c    s   ] ^ d t  |  f Sd  S(   Ns   %s/data/pid/%s.pid(   s
   TWCPERSDIRs   appName(   s   appName(    (    s	   istard.pys   makePidfileName] s   c    s   a b |  t | | f Sd  S(   N(   s   pid_types	   PERM_PROCs
   nice_levels   args(   s   pid_types   argss
   nice_level(    (    s	   istard.pys   permProca s   c    s   e f t  t t |  f Sd  S(   N(   s   NO_PIDs	   TEMP_PROCs   DFLT_PRIs   args(   s   args(    (    s	   istard.pys   tempProce s   c    s!   n o t  t |  |  g | ƒ Sd  S(   N(   s   permProcs   MK_PIDs   names   args(   s   names   args(    (    s	   istard.pys
   micoBinaryn s   c    s   r s t  d d |  g ƒ Sd  S(   Ns   sleep(   s   tempProcs   secs(   s   secs(    (    s	   istard.pys   sleepr s   c    s–   v w | t j o x |  } n y | t j	 o+ z |  | g t d t | f | g } n% | |  | g t d t | f g } } t t | | ƒ Sd  S(   Ns   %s/conf/%s.py(
   s   confs   Nones   procs   safeModes	   corbaArgss
   TWCPERSDIRs   argss   permProcs   WT_PIDs   pri(   s   procs   pris   confs   safeModes   args(    (    s	   istard.pys   istarBinaryv s   +$c    s   €  | t j o ‚ |  } n ƒ | t j o „ t } n … d | d | |  f d t | f g t } ˆ t t	 | | ƒ Sd  S(   Ns   pythons   %s/bin/%s/main.pycs   %s/conf/%s.py(   s   confs   Nones   scripts   dirs	   TWCCLIDIRs
   TWCPERSDIRs   omniOrbArgss   argss   permProcs   WT_PIDs   pri(   s   scripts   pris   confs   dirs   args(    (    s	   istard.pys   pythonDaemon€ s   -c    sU   ‹ Œ d |  d t |  f g }  | t j o Ž | | } n  t | t ƒ Sd  S(   Ns   pythons   %s/util/%s.pyc(   s   scripts	   TWCCLIDIRs   argvs   argss   Nones   tempProcs   omniOrbArgs(   s   scripts   argss   argv(    (    s	   istard.pys
   pythonUtil‹ s   c    s:   ’ “ d |  | f d t | ƒ g } ” t d | ƒ Sd  S(   Ns   %s.%ss   "%s"s   signalEvent(   s   procs   signals   reprs   argss   argvs
   pythonUtil(   s   procs   signals   argss   argv(    (    s	   istard.pys
   sendSignal’ s   #c    s%   — ˜ t  |  d |  d | f ƒ Sd  S(   Ns
   loadPlugins   .(   s
   sendSignals   procs   plugin(   s   procs   plugin(    (    s	   istard.pys
   loadPlugin— s   c    s'   › œ t  d d  d t |  f ƒ Sd  S(   Ns   playmans   playCmd.rsload.loads   %s/products/local(   s
   sendSignals
   TWCPERSDIRs   product(   s   product(    (    s	   istard.pys   loadProduct› s   c    s     ¡ t  d |  g ƒ Sd  S(   Ns   load(   s
   pythonUtils   script(   s   script(    (    s	   istard.pys   rsload  s   s   MyErrorc      s   § ¨ d „  Z  ª d „  Z RS(   Nc    s   ¨ © | |  _  d  S(   N(   s   values   self(   s   selfs   value(    (    s	   istard.pys   __init__¨ s   c    s   ª « |  i Sd  S(   N(   s   selfs   value(   s   self(    (    s	   istard.pys   __str__ª s   (   s   __init__s   __str__(    (    (    s	   istard.pys   MyError§ s   c    s4   ® ¯ t  i d |  ƒ ° t ƒ  ± t |  ƒ ‚ d  S(   Ns   Got signal %d(   s   Logs   errors   signums   disable_signal_handlers   MyError(   s   signums   frame(    (    s	   istard.pys   signal_handler® s   
c      sR   ³ µ t  i  t  i t  i ƒ ¶ t  i  t  i t  i ƒ · t  i  t  i t  i ƒ d  S(   N(   s   signals   SIGUSR1s   SIG_DFLs   SIGUSR2s   SIGTERM(    (    (    s	   istard.pys   disable_signal_handler³ s   c      sŽ   ¹ ¼ t  i d t i ƒ ½ t i t i t ƒ ¾ t  i d t i ƒ ¿ t i t i t ƒ À t  i d t i ƒ Á t i t i t ƒ d  S(   Ns#   trapping SIGUSR1 - signal number %ds#   trapping SIGUSR2 - signal number %ds#   trapping SIGTERM - signal number %d(   s   Logs   infos   signals   SIGUSR1s   signal_handlers   SIGUSR2s   SIGTERM(    (    (    s	   istard.pys   enable_signal_handler¹ s   c    s¶  Ã Ä x©|  DÄ ]ž\ } } } } É | d } Ê t | ƒ } Ì | t j oÎ t	 i
 i | ƒ o Ï t	 i | ƒ n Ñ t i d | d | d f ƒ Ò t	 i t	 i | d | d ƒ } Ô t i d | | f ƒ Õ | t | <× | t j oo Ù t i d ƒ Ý y7 Þ t | d ƒ } ß | i d | ƒ à | i ƒ  Wn á â t i d | ƒ n Xn¢ç d } è d	 }
 é d } ê d } ì x² ì | | j  o¡ ñ t i |
 ƒ ò | |
 } õ t	 i | t	 i  ƒ \ } }	 ö | | j o+ ÷ t i d
 | | t# |	 ƒ f ƒ ú Pn ü t	 i
 i | ƒ o þ d } ÿ Pn qW| d j oµ t i d | f ƒ t i d | t# |	 ƒ f ƒ yU t i d | ƒ 	t	 i$ | t% i& ƒ 
t	 i | d ƒ t i d | ƒ Wn n Xt' t% i( ƒ ‚ n | t) j o8 t i d | | f ƒ t	 i* d | | f ƒ n n_ t i d t+ i, | d  | d ƒ ƒ t	 i* t+ i, | d  | d ƒ ƒ t i d ƒ q Wd  S(   Ni   s   spawnvp args are %s %si    s   %s pid was %ds   ws   %d
s   unable to create pidfile %sf10.0f0.10000000000000001s   Pid %d (%s) %ss.   Process %s failed to start. Raising exception.s   cpid = %d: %ss   SIGKILL process pid = %d to dies   process %d dieds   doing renice %d -p %ds   sudo renice %d -p %ds   os.system args are %si   (-   s   commandLists   pidfile_types	   proc_types
   nice_levels   cmdlists   appNames   makePidfileNames   pidfileNames	   PERM_PROCs   oss   paths   isfiles   unlinks   Logs   infos   spawnvps   P_NOWAITs   pids   critical_pidss   MK_PIDs   times   sleeps   files   pidfiles   writes   closes   criticals	   timeLimits	   sleepTimes   elapsedTimes   founds   waitpids   WNOHANGs   cpids   cstats   exitDescriptions   kills   signals   SIGKILLs   MyErrors   SIGUSR1s   DFLT_PRIs   systems   strings   join(   s   commandLists   cpids   appNames   pids	   timeLimits
   nice_levels   cmdlists   pidfile_types	   proc_types   cstats	   sleepTimes   elapsedTimes   founds   pidfileNames   pidfile(    (    s	   istard.pys   start_processesÃ sf   
 "#				 #	 ")%c    s  t  i i |  ƒ oð!y¸"t t |  ƒ i ƒ  i ƒ  ƒ } #| d j oƒ$t	 i
 d | ƒ %y0't  i | t i ƒ *d } +d } ,x™ ,| d j  oˆ .t  i | t  i ƒ \ } } /| | j o% 0d } 1t	 i
 d | ƒ 2Pn2 4t	 i
 d | ƒ 5t i d ƒ 6| d 7} q˜ W9| d j oU :t	 i
 d | ƒ ;t  i | t i ƒ <t  i | d ƒ =t	 i
 d | ƒ n Wn5 ?t j
 o& } @t	 i
 d | i | f ƒ n Xn Wn ABt	 i d	 |  ƒ n XDt  i |  ƒ n d  S(
   Ni   s   SIGTERM process with pid = %di    i
   s   process %d dieds#   sleep waiting for process %d to dies   SIGKILL process pid = %d to dies   Error %d trying to kill %ds   Error getting pid from %s(   s   oss   paths   isfiles   pidFilenames   ints   opens   readlines   strips   pids   Logs   infos   kills   signals   SIGTERMs   ets   deads   waitpids   WNOHANGs   cpids   cstats   times   sleeps   SIGKILLs   OSErrors   es   errnos   errors   unlink(   s   pidFilenames   waits   es   cpids   pids   deads   cstats   et(    (    s	   istard.pys   kill_pidfiles:   !		 	*c    sj   FIx' t  DI] } Jt t | ƒ |  ƒ q WNx0 t i t d ƒ ƒ DN] } Ot | |  ƒ qI Wd  S(   Ns   *(   s   stopCmdLists   appNames   kill_pidfiles   makePidfileNames   waits   globs   pidFilename(   s   waits   appNames   pidFilename(    (    s	   istard.pys   stop_processesFs   
 	 	c     sH   QRd }  Sx" t DS] } T|  d | 7}  q WUt i |  ƒ d  S(   Ns   ps | grep -v grep | egrep s   -e "%s" (   s   cmds   stopCmdLists   names   oss   system(   s   cmds   name(    (    s	   istard.pys   disp_processesQs
   	
 	c     sõ   WXt  i  ƒ  } YxÙ Yd oÎ Zt i d ƒ [t i ƒ  \ }  } \t i	 |  ƒ ol ]t i
 d t |  |  t | ƒ f ƒ bt  i  ƒ  | d j  o ct t i ƒ ‚ n ft d ƒ iPn' kt i d |  t | ƒ f ƒ mq q Wd  S(   Ni   s"   Waiting for a child process to dies&   Permament child process %s (pid %d) %ss#   Temporary child process (pid %d) %s(   s   times   starts   Logs   infos   oss   waits   cpids   cstats   critical_pidss   has_keys   criticals   exitDescriptions   MyErrors   signals   SIGUSR1s   stop_processess   error(   s   cpids   starts   cstat(    (    s	   istard.pys   listen_for_dead_child_processesWs    
' c    sœ  opt  ƒ  rd } sd } t|  GHuxN|  Du]C\ } } vd } wxÒw| | j oÁxyu zh  } || | j oX }| d } ~t | ƒ t	 ƒ  €d } | o ‚d } n ƒt
 i d ƒ n WnB…t j
 oý } †t
 i d | i ƒ ‡| i t i j o! ˆt
 i d ƒ ‰t d ƒ n Š| i t i j oI ‹t
 i d ƒ Œd GHt i d ƒ Žt d ƒ t i d ƒ n | i t i j o1 ‘t
 i d ƒ ’t d ƒ “t i d ƒ n n8 •–t
 i d	 ƒ —t d ƒ ˜t i d
 ƒ n XqO W™| o | o< št
 i d ƒ ›d GHœt i d ƒ t i d ƒ n žd } q1 W t
 i d ƒ ¡t i ƒ  d  S(   Ni   i    s.   Child process died. Need to RESTART processes.s!   MyError exception - signal was %ds%   SIGUSR1 triggered. Stopping processess   REBOOTING system in 1 minutes   shutdown -r +1s%   SIGTERM triggered. Stopping processess   Unexpected exception.iþÿÿÿs    REBOOTING due to restart failures   shutdown -r nows(   Failed all attempts to restart. Hanging.(   s   enable_signal_handlers   firsts   successful_runs   commandListss   command_lists   max_attemptss   attempts_mades   critical_pidss   start_processess   listen_for_dead_child_processess   Logs   criticals   MyErrors   es   values   signals   SIGUSR1s   infos   stop_processess   SIGUSR2s   oss   systems   syss   exits   SIGTERMs   pause(   s   commandListss   es   command_lists   critical_pidss   attempts_mades   max_attemptss   successful_runs   first(    (    s	   istard.pys   spawn_processesos\   
		
 	 	
	
s   istardi   s	   TWCCLIDIRs*   No TWCCLIDIR environment variable defined!iÿÿÿÿs
   TWCPERSDIRs+   No TWCPERSDIR environment variable defined!s   Error: stopCmdList is emptys   Error: startCmdList is emptys    Error: startDataCmdList is emptys$   Error: startSafeModeCmdList is emptys	   Error: %ss   starts	   startdatas   startsafemodes   stops   statuss   spawns   Unknown argument: %s(G   s   oss   syss   times   strings   signals   globs   twcs   twccommon.Logs	   twccommons   Logs	   TEMP_PROCs	   PERM_PROCs   HIGH_PRIs   DFLT_PRIs   LOW_PRIs   NO_PIDs   MK_PIDs   WT_PIDs   hostNames   basePorts   eventChannelNameArgs   nsdArgss   orbNameArgss	   corbaArgss   omniOrbArgss   usages   exitDescriptions   makePidfileNames   permProcs   tempProcs
   micoBinarys   sleeps   Nones   istarBinarys   pythonDaemons
   pythonUtils
   sendSignals
   loadPlugins   loadProducts   rsloads	   Exceptions   MyErrors   signal_handlers   disable_signal_handlers   enable_signal_handlers   start_processess   kill_pidfiles   stop_processess   disp_processess   listen_for_dead_child_processess   spawn_processess   setIdents   setLevels   INFOs   lens   argvs   exits   environs	   TWCCLIDIRs   criticals
   TWCPERSDIRs   execfiles   stopCmdLists   startCmdLists   startDataCmdLists   startSafeModeCmdLists	   NameErrors   es   __str__s   critical_pidss   ListOfCmdLists(5   s	   PERM_PROCs   Logs   loadProducts   hostNames   omniOrbArgss
   loadPlugins   sleeps   MK_PIDs   WT_PIDs   twcs   rsloads   signals   pythonDaemons
   sendSignals
   micoBinarys   spawn_processess   exitDescriptions   disp_processess   critical_pidss   tempProcs   usages   listen_for_dead_child_processess   basePorts   nsdArgss   disable_signal_handlers   permProcs   MyErrors   strings   orbNameArgss   enable_signal_handlers   globs   syss   kill_pidfiles   ListOfCmdListss	   TWCCLIDIRs   makePidfileNames
   TWCPERSDIRs   NO_PIDs   LOW_PRIs   start_processess   stop_processess   signal_handlers   es   istarBinarys   DFLT_PRIs   HIGH_PRIs   eventChannelNameArgs
   pythonUtils	   twccommons   times	   TEMP_PROCs   oss	   corbaArgs(    (    s	   istard.pys   ? s¾   												

Z)<
&	$