def __init__(self, module): ''' Constructor ''' guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) appServer = ApplicationServer(module, scriptGlobals.appsrvProperties) pid = getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, appServer.processIdentifier) if pid: log.error("Already existing process running from path '" + module.targetDeploymentPath + "' with pid '" + pid + "'.") else: # Delete all cached directories log.info("Proceeding to delete all cached folders") try: for i in appServer.relativeCacheFolders: deleteDirOrFile(module.targetDeploymentPath + scriptGlobals.osDirSeparator + i) 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(module.targetDeploymentPath + appServer.binPath) runProcess("." + scriptGlobals.osDirSeparator + appServer.startCommand) 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.name + "@"+ getCurrentHostname() + " (" + module.friendlyServerName + ")" emailText = startApplicationServerNotificationTemplate(module.name, getCurrentHostname(), guid) # Email all required parties SendEmail(emailSender, emailRecipients, emailSubject, emailText, scriptGlobals.smtpHost, scriptGlobals.smtpPort)
def undo(self): deleteDirOrFile(self.dst)