def check4server(config): if os.path.exists(config.SOCKETPATH): if os.path.exists(config.PIDFILE): pid = int(open(config.PIDFILE).read().strip()) s = procfs.ProcStat(pid) if s and s.command.find(config.SERVERNAME) >= 0: return pid return 0
def status(config): from pycopia.OS import procfs if os.path.exists(config.PIDFILE): pid = int(open(config.PIDFILE).read().strip()) s = procfs.ProcStat(pid) if s and s.command.find(config.SERVERNAME) >= 0: print "Process manager running: pid %s: %s." % (pid, s.cmdline) return 0 print "Process manager not running." return 1