def getPidStatus(self, seg, pidRunningStatus): """ returns a dict containing "pid" and "error" fields. Note that the "error" field may be non-None even when pid is non-zero (pid if zero indicates unable to determine the pid). This can happen if the pid is there in the lock file but not active on the port. The caller can rely on this to try to differentiate between an active pid and an inactive one """ lockFileExists = pidRunningStatus['lockFileExists'] netstatPortActive = pidRunningStatus['netstatPortActive'] pidValue = pidRunningStatus['pidValue'] lockFileName = gp.get_lockfile_name(seg.getSegmentPort()) error = None if not lockFileExists and not netstatPortActive: error = "No socket connection or lock file (%s) found for port %s" % ( lockFileName, seg.getSegmentPort()) elif not lockFileExists and netstatPortActive: error = "No lock file %s but process running on port %s" % ( lockFileName, seg.getSegmentPort()) elif lockFileExists and not netstatPortActive: error = "Have lock file %s but no process running on port %s" % ( lockFileName, seg.getSegmentPort()) else: if pidValue == 0: error = "Have lock file and process is active, but did not get a pid value" # this could be an assert? res = {} res['pid'] = pidValue res['error'] = error return res
def getPidStatus(self, seg, pidRunningStatus): """ returns a dict containing "pid" and "error" fields. Note that the "error" field may be non-None even when pid is non-zero (pid if zero indicates unable to determine the pid). This can happen if the pid is there in the lock file but not active on the port. The caller can rely on this to try to differentiate between an active pid and an inactive one """ lockFileExists = pidRunningStatus['lockFileExists'] netstatPortActive = pidRunningStatus['netstatPortActive'] pidValue = pidRunningStatus['pidValue'] lockFileName = gp.get_lockfile_name(seg.getSegmentPort()) error = None if not lockFileExists and not netstatPortActive: error = "No socket connection or lock file (%s) found for port %s" % (lockFileName, seg.getSegmentPort()) elif not lockFileExists and netstatPortActive: error = "No lock file %s but process running on port %s" % (lockFileName, seg.getSegmentPort()) elif lockFileExists and not netstatPortActive: error = "Have lock file %s but no process running on port %s" % (lockFileName, seg.getSegmentPort()) else: if pidValue == 0: error = "Have lock file and process is active, but did not get a pid value" # this could be an assert? res = {} res['pid'] = pidValue res['error'] = error return res