lib/srv_manager/process.rb in srv_manager-0.0.4 vs lib/srv_manager/process.rb in srv_manager-0.0.5

- old
+ new

@@ -9,10 +9,11 @@ end def start return if alive? command.rvm ? rvm_start : default_start + @id = wait_for_pid(command.pidfile) if command.pidfile LOGGER.info "Started process #{@id}" end def stop return unless started? @@ -40,11 +41,15 @@ end private def detault_start - @id = ::Process.spawn command.env, command.text, chdir: command.dir, out: '/dev/null', err: '/dev/null' + @id = ::Process.spawn command.env, + command.text, + chdir: command.dir, + out: '/dev/null', + err: '/dev/null' ::Process.detach @id end def rvm_start pid_file = File.expand_path "#{self.object_id}_#{Time.now.to_i}.pid", TMP_PATH @@ -52,18 +57,18 @@ RVM_RUNNER, chdir: command.dir, out: '/dev/null', err: '/dev/null' ::Process.detach rvm_pid - @id = wait_for_pid pid_file + @id = wait_for_pid pid_file, true end - def wait_for_pid(filename) + def wait_for_pid(filename, delete=false) Timeout.timeout(60) do loop do if File.exists? filename pid = File.read(filename).to_i - File.delete filename + File.delete filename if delete return pid end sleep 0.1 end end \ No newline at end of file