Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Mooney committed Mar 15, 2011
1 parent d8e27b9 commit 46de416
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions lib/start.rb
Expand Up @@ -24,17 +24,15 @@ def root_path
File.dirname(__FILE__) + "/../"
end

def empty_pid_file
if File.exists?(pid_file_path)
File.open(pid_file_path, 'w') {|f| f.write("")}
end
def delete_pid_file
%x{rm #{pid_file_path}} if File.exists?(pid_file_path)
end

if pid = get_pid("node server.js")
File.open(pid_file_path, 'w') {|f| f.write(pid)}
puts "Already runnning with pid #{pid}."
else
empty_pid_file
delete_pid_file
%x{mkdir -p /var/run}
ppid = IO.popen("cd #{root_path} && node server.js &> /var/log/node.log").pid
if (pid = get_child_process(ppid))
Expand Down
8 changes: 3 additions & 5 deletions lib/stop.rb
Expand Up @@ -12,10 +12,8 @@ def pid_file_path
"/var/run/juggernaut.pid"
end

def empty_pid_file
if File.exists?(pid_file_path)
File.open(pid_file_path, 'w') {|f| f.write("")}
end
def delete_pid_file
%x{rm #{pid_file_path}} if File.exists?(pid_file_path)
end

(pids = get_pids("node server.js")).each do |pid|
Expand All @@ -26,4 +24,4 @@ def empty_pid_file
else
puts "Stopped node server."
end
empty_pid_file
delete_pid_file

0 comments on commit 46de416

Please sign in to comment.