- if not self.get("command"):
- self.set("command", self._start_command)
-
- if not self.get("depends"):
- self.set("depends", self._dependencies)
-
- if not self.get("sources"):
- self.set("sources", self._sources)
-
- sources = self.get("sources")
- source = sources.split(" ")[0]
- basename = os.path.basename(source)
- self._version = ( basename.strip().replace(".tar.gz", "")
- .replace(".tar","")
- .replace(".gz","")
- .replace(".zip","") )
-
- if not self.get("build"):
- self.set("build", self._build)
-
- if not self.get("install"):
- self.set("install", self._install)
-
- if not self.get("env"):
- self.set("env", self._environment)
-
- command = self.get("command")
- env = self.get("env")
-
- self.info("Deploying command '%s' " % command)
-
- # create home dir for application
- self.node.mkdir(self.run_home)
-
- # upload sources
- self.upload_sources()
-
- # upload code
- self.upload_code()
-
- # upload stdin
- self.upload_stdin()
-
- # install dependencies
- self.install_dependencies()
-
- # build
- self.build()
+ try:
+ if not self.get("command"):
+ self.set("command", self._start_command)
+
+ if not self.get("depends"):
+ self.set("depends", self._dependencies)
+
+ if not self.get("sources"):
+ self.set("sources", self._sources)
+
+ sources = self.get("sources")
+ source = sources.split(" ")[0]
+ basename = os.path.basename(source)
+ self._version = ( basename.strip().replace(".tar.gz", "")
+ .replace(".tar","")
+ .replace(".gz","")
+ .replace(".zip","") )
+
+ if not self.get("build"):
+ self.set("build", self._build)
+
+ if not self.get("install"):
+ self.set("install", self._install)
+
+ if not self.get("env"):
+ self.set("env", self._environment)
+
+ command = self.get("command")
+
+ self.info("Deploying command '%s' " % command)
+
+ self.discover()
+ self.provision()
+ except:
+ self.fail()
+ raise
+
+ self.debug("----- READY ---- ")
+ self._ready_time = tnow()
+ self._state = ResourceState.READY