diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-08-19 14:38:31 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-08-21 05:44:11 +0900 |
commit | 2904ee23bfc1a442b801f0d35e8e49d51a6d47b6 (patch) | |
tree | 47e934d8c73aa67ac13ae7e7a6440716d740f73d /railties/lib/rails | |
parent | 99c604f1f9de2f2a6fc3d0aec4f274cb05b48c69 (diff) | |
download | rails-2904ee23bfc1a442b801f0d35e8e49d51a6d47b6.tar.gz rails-2904ee23bfc1a442b801f0d35e8e49d51a6d47b6.tar.bz2 rails-2904ee23bfc1a442b801f0d35e8e49d51a6d47b6.zip |
Make `restart` and `dev:cache` tasks work when customizing pid file path
Originally, it hard-coded pid file path. It can not be removed when customizing
pid file path.
But rake task can not get pid file path. Therefore, do not remove file in rake
task, makes it possible to judge whether it is restart from the argument of the
command and removes the file in server command.
Fixes #29306
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/commands/server/server_command.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/dev_caching.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/tasks/restart.rake | 1 |
3 files changed, 7 insertions, 3 deletions
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb index 88e5698714..785265d766 100644 --- a/railties/lib/rails/commands/server/server_command.rb +++ b/railties/lib/rails/commands/server/server_command.rb @@ -126,6 +126,7 @@ module Rails desc: "Specifies the PID file." class_option "dev-caching", aliases: "-C", type: :boolean, default: nil, desc: "Specifies whether to perform caching in development." + class_option "restart", type: :boolean, default: nil, hide: true def initialize(args = [], local_options = {}, config = {}) @original_options = local_options @@ -136,6 +137,7 @@ module Rails def perform set_application_directory! + prepare_restart Rails::Server.new(server_options).tap do |server| # Require application after server sets environment to propagate # the --environment option. @@ -222,7 +224,7 @@ module Rails end def restart_command - "bin/rails server #{@server} #{@original_options.join(" ")}" + "bin/rails server #{@server} #{@original_options.join(" ")} --restart" end def pid @@ -232,6 +234,10 @@ module Rails def self.banner(*) "rails server [puma, thin etc] [options]" end + + def prepare_restart + FileUtils.rm_f(options[:pid]) if options[:restart] + end end end end diff --git a/railties/lib/rails/dev_caching.rb b/railties/lib/rails/dev_caching.rb index efb523de4c..ff629b2527 100644 --- a/railties/lib/rails/dev_caching.rb +++ b/railties/lib/rails/dev_caching.rb @@ -19,7 +19,6 @@ module Rails end FileUtils.touch "tmp/restart.txt" - FileUtils.rm_f("tmp/pids/server.pid") end def enable_by_argument(caching) diff --git a/railties/lib/rails/tasks/restart.rake b/railties/lib/rails/tasks/restart.rake index 5b6bb8ddd6..074e3e89a1 100644 --- a/railties/lib/rails/tasks/restart.rake +++ b/railties/lib/rails/tasks/restart.rake @@ -5,6 +5,5 @@ task :restart do verbose(false) do mkdir_p "tmp" touch "tmp/restart.txt" - rm_f "tmp/pids/server.pid" end end |