-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
83 lines (62 loc) · 2.06 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
dev = !ENV.key?("CAMPING_ENV") || ENV["CAMPING_ENV"] == "development"
prod = !dev
desc "Starts the server using rackup for development"
task :start_rackup_development do
system("rackup _1.1.0_ -p 8005 -E none init/camping.ru")
end
desc "Starts the server using rackup for production"
task :start_rackup_production do
system("rackup _1.1.0_ -p 8004 -E none -P #{File.dirname(__FILE__)}/tmp/pids/rack.pid init/camping.ru &")
end
desc "Starts the server using rackup for the current environment"
task :start_rackup do
Rake::Task[dev ? "start_rackup_development" : "start_rackup_production"].invoke
end
task :sr => :start_rackup
task :stop_rackup_production do
#Find out why failing in monit
# system("kill `cat tmp/pids/rack.pid`") if File.exists?("tmp/pids/rack.pid")
# sleep(5)
system("kill -9 `cat tmp/pids/rack.pid`") if File.exists?("tmp/pids/rack.pid")
end
task :restart_rackup_production => [:stop_rackup_production, :start_rackup_production] #test
desc "Starts the server using camping's builtin server"
task :start_camping do
#bad example with ARGV
system("scripts/camping.rb #{ARGV[1]}")
end
task :sc => :start_camping
desc "Clear caches"
task :clear_caches do
Dir.glob("./*/public/cache/*").each { |dir| FileUtils.rm(dir) }
end
desc "Generate nginx configuration"
task :generate_nginx_config do
require 'date'
f = File.open("/www/camping_apps/shared/lib/camping_apps.conf", "w")
f << "# DO NOT EDIT this file; it was generated by #{__FILE__} at #{DateTime.now.strftime("%d/%m/%Y %I:%M%p")}\n\n"
Dir.glob("*.rb").map { |d| File.basename(d, ".rb") }.each do |name|
f << <<-EOF
# Configuration for #{name}
server {
listen 80;
server_name www.#{name}.bloople.net;
rewrite ^/(.*) http://#{name}.bloople.net/$1 permanent;
}
server {
listen 80;
server_name #{name}.bloople.net;
location / {
root /www/camping_apps/current/#{name}/public/;
index /;
if (!-f $request_filename) {
rewrite ^/(.*) /#{name}/$1 break;
proxy_pass http://127.0.0.1:8004;
}
include /etc/nginx/proxy.conf;
}
}
EOF
end
f.close
end