-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathRakefile
36 lines (29 loc) · 845 Bytes
/
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
if File.exist? "spec"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
end
def app?
File.exist? "config.ru"
end
def app_name
"hackersays"
end
if app?
desc "Restart app"
task :restart => [:stop, :start]
desc "Start app"
task :start => [:stop, :environment] do
`
RACK_ENV=production bundle exec rackup -s puma -o 127.0.0.1 >>/var/log/#{app_name}/#{app_name}.log 2>&1 &
echo $! > /var/run/#{app_name}/#{app_name}.pid
`
end
desc "Stop app"
task :stop => :environment do
`if [ -f /var/run/#{app_name}/#{app_name}.pid ]; then kill -9 $(cat /var/run/#{app_name}/#{app_name}.pid) 2>/dev/null && rm -f /var/run/#{app_name}/#{app_name}.pid || echo "#{app_name} was not running..."; fi`
end
task :environment do
Dir.chdir File.expand_path(File.dirname(__FILE__))
end
end
task :default => :spec