def start_from_binary(self): microservice_target_path = self.context.get_microservice_target_path(self.service_name) force_chdir(microservice_target_path) if not self.context.offline: nexus = SmNexus(self.context, self.service_name) nexus.download_jar_if_necessary(self.run_from, self.version) filename = self._get_jar_filename() service_data = self.service_data binary_data = service_data["binary"] if "configurationFile" in binary_data: configuration_file = binary_data["configurationFile"] else: print "ERROR: required config 'configurationFile' does not exist" return None binary_to_run = os.path.join(microservice_target_path, filename) if os.path.exists(binary_to_run): force_chdir(self.run_from) os.system("jar xvf " + microservice_target_path + filename + " " + configuration_file + " > /dev/null") force_chdir(microservice_target_path) cmd = self.get_start_command("BINARY") process = Popen(cmd, env=os.environ.copy(), stdout=SmDropwizardServiceStarter.DEV_NULL, stderr=SmDropwizardServiceStarter.DEV_NULL, close_fds=True) if process.returncode == 1: print b.fail + "ERROR: could not start '" + self.service_name + "' " + b.endc else: self.context.log("'%s' version '%s' started successfully" % (self.service_name, self.version)) return process.pid else: print "ERROR: the requested file: '" + binary_to_run + "' does not exist" return None
def _start_from_binary(self): assets_target_path = self.context.get_microservice_target_path(self.service_name) assets_path = self.context.application.workspace + self.service_data["location"] force_chdir(assets_path) remove_if_exists("RUNNING_FROM") force_chdir(assets_target_path) if not self.context.offline: nexus = SmNexus(self.context, self.service_name) if self.version: versions = [ self.version ] elif self.context.assets_versions: versions = self.context.assets_versions self.log("Starting assets versions: %s" % (", ".join(versions))) else: versions = nexus.get_all_versions(self.run_from) for version in versions: nexus.download_jar_if_necessary(self.run_from, version) self._unzip_assets(versions) cmd_with_params = self.service_data["binary"]["cmd"] makedirs_if_not_exists("logs") with open("logs/stdout.txt", "wb") as out, open("logs/stderr.txt", "wb") as err: return subprocess.Popen(cmd_with_params[0].split(), shell=False, env=os.environ.copy(), stdout=out, stderr=err, close_fds=True).pid
def _start_from_binary(self): assets_target_path = self.context.get_microservice_target_path( self.service_name) assets_path = self.context.application.workspace + self.service_data[ "location"] force_chdir(assets_path) remove_if_exists("RUNNING_FROM") force_chdir(assets_target_path) if not self.context.offline: nexus = SmNexus(self.context, self.service_name) versions = nexus.get_all_versions(self.version, self.run_from) for version in versions: nexus.download_jar_if_necessary(self.run_from, version) self._unzip_assets(versions) cmd_with_params = self.service_data["binary"]["cmd"] makedirs_if_not_exists("logs") with open("logs/stdout.txt", "wb") as out, open("logs/stderr.txt", "wb") as err: return subprocess.Popen(cmd_with_params[0].split(), shell=False, env=os.environ.copy(), stdout=out, stderr=err, close_fds=True).pid
def start_from_binary(self): microservice_target_path = self.context.get_microservice_target_path( self.service_name) force_chdir(microservice_target_path) if not self.context.offline: nexus = SmNexus(self.context, self.service_name) nexus.download_jar_if_necessary(self.run_from, self.version) filename = self._get_jar_filename() service_data = self.service_data binary_data = service_data["binary"] if "configurationFile" in binary_data: configuration_file = binary_data["configurationFile"] else: print "ERROR: required config 'configurationFile' does not exist" return None binary_to_run = os.path.join(microservice_target_path, filename) if os.path.exists(binary_to_run): force_chdir(self.run_from) os.system("jar xvf " + microservice_target_path + filename + " " + configuration_file + " > /dev/null") force_chdir(microservice_target_path) cmd = self.get_start_command("BINARY") process = Popen(cmd, env=os.environ.copy(), stdout=SmDropwizardServiceStarter.DEV_NULL, stderr=SmDropwizardServiceStarter.DEV_NULL, close_fds=True) if process.returncode == 1: print b.fail + "ERROR: could not start '" + self.service_name + "' " + b.endc else: self.context.log("'%s' version '%s' started successfully" % (self.service_name, self.version)) return process.pid else: print "ERROR: the requested file: '" + binary_to_run + "' does not exist" return None