Skip to content

Commit

Permalink
Created rake restart task.
Browse files Browse the repository at this point in the history
Fixes rails#18876. Rake restart touches `tmp/restart.txt` to restart
application on next request. Updated tests and documentation
accordingly.
  • Loading branch information
hjoo committed Feb 26, 2015
1 parent 3821892 commit b181297
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
* Created rake restart task. Restarts your Rails app by touching the
`tmp/restart.txt`.

Fixes #18876.

*Hyonjee Joo*

* Set Rails console to use log formatter and log level as specified for the
given environment.

Expand Down
1 change: 1 addition & 0 deletions railties/lib/rails/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
log
middleware
misc
restart
routes
statistics
tmp
Expand Down
4 changes: 4 additions & 0 deletions railties/lib/rails/tasks/restart.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
desc "Restart app by touching tmp/restart.txt"
task restart: :environment do
FileUtils.touch('tmp/restart.txt')
end
31 changes: 31 additions & 0 deletions railties/test/application/rake/restart_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require "isolation/abstract_unit"

module ApplicationTests
module RakeTests
class RakeRestartTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation

def setup
build_app
boot_rails
end

def teardown
teardown_app
end

test 'rake restart touches tmp/restart.txt' do
Dir.chdir(app_path) do
`rake restart`
assert File.exist?("tmp/restart.txt")

prev_mtime = File.mtime("tmp/restart.txt")
sleep(1)
`rake restart`
curr_mtime = File.mtime("tmp/restart.txt")
assert_not_equal prev_mtime, curr_mtime
end
end
end
end
end

0 comments on commit b181297

Please sign in to comment.