def __init__(self, module): ''' Constructor ''' guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) pid = getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, module.subModule.processIdentifier) # If process exists... if pid: # Kill process using pid killProcess(pid) # Construct the email notification emailSender = readPropertyFromPropertiesFileWithFallback("emailNotificationSenderAddress", scriptGlobals.scriptVarSectionName, lib.OptParser.options.envprops, scriptGlobals.emailNotificationSenderAddress) emailRecipients = module.emailNotificationRecipientList emailSubject = "Server KILL: " + module.subModule.name + "@"+ getCurrentHostname() + " (" + module.friendlyServerName + ")" emailText = killApplicationServerNotificationTemplate(module.name, getCurrentHostname(), guid) # Email all required parties SendEmail(emailSender, emailRecipients, emailSubject, emailText, scriptGlobals.smtpHost, scriptGlobals.smtpPort)
def __init__(self, module): ''' Constructor ''' guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) # appServer = ApplicationServer(module, scriptGlobals.appsrvProperties) pid = getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, module.subModule.processIdentifier) bin_path=module.targetDeploymentPath + "/" + module.subModule.name + "/bin/" if pid: log.info("\n\nAlready existing process running from path '" + module.targetDeploymentPath + "' with pid '" + pid + "'.\n") log.info("\n\Proceeding with Killing the Server") # Kill process using pid killProcess(pid) # Delete all cached directories log.info("Proceeding to delete nohup file") try: deleteDirOrFile(bin_path + "nohup.out") except OSError: # If directory doesn't exist ignore the raised error pass # Change directory to run the binary from inside the binpath pwd = os.getcwd() os.chdir(bin_path) ChangePathPermissions(bin_path + "start.sh", 0744) runProcess("nohup ./start.sh") os.chdir(pwd) # Construct the email notification emailSender = readPropertyFromPropertiesFileWithFallback("emailNotificationSenderAddress", scriptGlobals.scriptVarSectionName, lib.OptParser.options.envprops, scriptGlobals.emailNotificationSenderAddress) emailRecipients = module.emailNotificationRecipientList emailSubject = "Server START: " + module.subModule.name + "@"+ getCurrentHostname() + " (" + module.friendlyServerName + ")" emailText = startApplicationServerNotificationTemplate(module.name, getCurrentHostname(), guid) # Email all required parties SendEmail(emailSender, emailRecipients, emailSubject, emailText, scriptGlobals.smtpHost, scriptGlobals.smtpPort)