Skip to content

Commit

Permalink
Merge pull request #40 from tbrand/patch-2
Browse files Browse the repository at this point in the history
Patch 2
  • Loading branch information
tbrand authored May 13, 2017
2 parents c956a75 + b9f6c1a commit a966d2e
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions benchmarker/src/benchmarker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,15 @@ class ExecServer

# Kill the server process
def kill
@process.not_nil!.kill

# Since ruby's frameworks are running on puma, we have to kill the independent process
if @target.name == "rails" ||
@target.name == "roda" ||
@target.name == "sinatra"
kill_proc("puma")
elsif @target.name == "express"
kill_proc("node")
elsif @target.name == "plug"
if @target.name == "plug"
path = File.expand_path("../../../elixir/plug/_build/prod/rel/my_plug/bin/my_plug", __FILE__)
Process.run("bash #{path} stop", shell: true)
elsif @target.name == "phoenix"
path = File.expand_path("../../../elixir/phoenix/_build/prod/rel/my_phoenix/bin/my_phoenix", __FILE__)
Process.run("bash #{path} stop", shell: true)
end
end

def kill_proc(proc : String)
# Search pid of the process
proc = `ps aux | grep #{proc} | grep -v grep`
proc.split(" ").each do |pid|
if /\d+/ =~ pid
_pid = $~[0].to_i
Process.kill(Signal::TERM, _pid)
break
end
end
# kill the server_lang_framework @process AND it's children
Process.run("pkill -9 -g $(ps -o pgid= #{@process.pid} | grep -o [0-9]*)", shell: true)
end
end

Expand Down

0 comments on commit a966d2e

Please sign in to comment.