bin/baleen-server in baleen-0.0.9 vs bin/baleen-server in baleen-0.0.10

- old
+ new

@@ -2,29 +2,33 @@ require "thor" require "baleen" def pid - ### Use this when implement restart command - #pid = `ps ax | grep -E "baleen-server start|restart" | grep -v grep | awk '{print $1}'` pid = `ps ax | grep -E "baleen-server start|restart" | grep -v grep | awk '{print $1}'` pid.split("\n") end def running? - pid.size >= 1 + if pid.size == 0 + false + elsif pid.first.to_i == Process.pid + false + else + true + end end class BaleenServerCli < Thor desc "start", "Start Baleen server" option :docker_host, :default => "127.0.0.1" option :docker_port, :default => 4243 option :port, :default => 5533 option :debug, :type => :boolean def start - if pid.size > 1 + if running? warning "baleen-server is already running" warning "Exiting..." exit end @@ -53,8 +57,13 @@ else notice "baleen-server is not running" end end + desc "restart", "Restart Baleen server" + def restart + self.stop + self.start + end end BaleenServerCli.start