Skip to content
This repository has been archived by the owner on Jan 24, 2020. It is now read-only.

Commit

Permalink
move runner to external script
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarchie committed Sep 5, 2012
1 parent af3116c commit 2030592
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
28 changes: 13 additions & 15 deletions lib/language_pack/nginx.rb
Expand Up @@ -27,31 +27,29 @@ def default_config_vars

def default_process_types
{
"web" => 'ruby run.rb'
"web" => 'ruby runner.rb'
}
end

def compile
download_openresty
copy_runner
FileUtils.mkdir_p "logs"
File.open("run.rb", "w") do |file|
file.puts <<-APPLICATION
#!/usr/bin/env ruby
conf_file = File.read("nginx.conf")
conf_file.gsub!(/\\$ENV_(\\w+)/) do
ENV[$1]
end
File.open(".env_nginx.conf","w") do |file|
file.puts conf_file
end
`nginx -c \\`pwd\\`/.env_nginx.conf -g "daemon off;"`
APPLICATION
end
FileUtils.mkdir_p "tmp"
end

private

def copy_runner
runner_path = "runner.rb"
unless cache_load(runner_path)
Dir.chdir(build_path) do
run("cp #{File.join(File.dirname(__FILE__), "scripts", "runner.rb")} runner.rb")
cache_load(runner_path)
end
end
end

def download_openresty
openresty_path = "openresty"
topic "Installing OpenResty version #{OPENRESTY_STABLE_VERSION}"
Expand Down
6 changes: 6 additions & 0 deletions lib/language_pack/scripts/runner.rb
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

modified_filename = "nginx-#{Time.now.to_i}.conf"
conf_file = File.read("nginx.conf").gsub!(/\$ENV_(\w+)/) { ENV[$1] }
File.open(modified_filename, "w") {|f| f.puts conf_file }
%x{nginx -c \`pwd\`/#{modified_filename} -g "daemon off;"}
6 changes: 6 additions & 0 deletions scripts/runner.rb
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

modified_filename = "nginx-#{Time.now.to_i}.conf"
conf_file = File.read("nginx.conf").gsub!(/\$ENV_(\w+)/) { ENV[$1] }
File.open(modified_filename, "w") {|f| f.puts conf_file }
%x{nginx -c \`pwd\`/#{modified_filename} -g "daemon off;"}

0 comments on commit 2030592

Please sign in to comment.