aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/server
Commit message (Collapse)AuthorAgeFilesLines
* Properly expand the environment's name in all commandsyuuji.yaginuma2019-03-151-2/+4
| | | | | | | | | | | | | Since 3777701f1380f3814bd5313b225586dec64d4104, the environment's name is automatically expanded in console and dbconsole commands. In order to match the behavior between the commands, fixes it to have the same behavior of all the commands. This behavior is defined in `EnvironmentArgument`. Since `EnvironmentArgument` also defines the environment option, it is reused. However, since desc was not content that can be used in all comments, fixed desc to be defined for each command.
* Merge pull request #35568 from prathamesh-sonpatki/server_squishRyuta Kamizono2019-03-111-1/+1
|\ | | | | Squish the deprecation messages across the codebase
| * Squish the deprecation messages across the codebasePrathamesh Sonpatki2019-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sample example -> Before: prathamesh@Prathameshs-MacBook-Pro-2 blog *$ rails server thin DEPRECATION WARNING: Passing the Rack server name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -u option instead. After: prathamesh@Prathameshs-MacBook-Pro-2 squish_app *$ rails server thin DEPRECATION WARNING: Passing the Rack server name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -u option instead.
* | Merge pull request #35569 from prathamesh-sonpatki/env-varsKasper Timm Hansen2019-03-111-2/+2
|\ \ | | | | | | Mention `environment variable` instead of just `environment`
| * | Mention `environment variable` instead of just `environment`Prathamesh Sonpatki2019-03-111-2/+2
| |/
* / Use the -u switch for the `rails server` bannerPrathamesh Sonpatki2019-03-111-1/+1
|/ | | | | - Because just passing the server argument to this command is deprecated in https://github.com/rails/rails/pull/32058
* Revert "Remove deprecated `server` argument from the rails server command"yuuji.yaginuma2019-01-181-2/+21
| | | | | | This reverts commit fa791fb8e2a718b5d0430c7ca5a454678dfc192d. Reason: `server` argument was deprecated in Rails 6.0. Ref: #32058.
* Remove deprecated `server` argument from the rails server commandRafael Mendonça França2019-01-171-21/+2
|
* Remove deprecated support to old `config.ru` that use the application class ↵Rafael Mendonça França2019-01-171-13/+0
| | | | as argument of `run`
* Do not show suggestion message when not exist suggestionyuuji.yaginuma2018-12-291-1/+2
| | | | | | | | | | | | | | | | | | **before** ``` $ ./bin/rails g g Could not find generator 'g'. Maybe you meant nil? Run `rails generate --help` for more options. ``` **after** ``` $ ./bin/rails g g Could not find generator 'g'. Run `rails generate --help` for more options. ```
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* Fix the obvious typos detected by github.com/client9/misspellKazuhiro Sera2018-08-081-1/+1
|
* Merge pull request #28266 from Stellenticket/allow_disable_server_stdout_loggingKasper Timm Hansen2018-07-081-2/+9
|\ | | | | rails server: Allow to explicitly specify whether to output Rails's log to stdout
| * Allow to explicitly specify whether to output Rails' log to stdoutMarkus Doits2018-07-081-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before Rails' logger output is mirrored to std out if: * environment is development and * the process is not daemonized It was not possible to change that behaviour, e.g. to disable log output in that case or enable it in other cases. Now you can explicitly disable or enable output with the new command line switch `--log-to-stdout`, regardless of any other circumstances. ``` // enable output in production rails server -e production --log-to-stdout // disable output in development rails server -e development --no-log-to-stdout ``` Enabling output when daemonized still makes no sense (since tty is detached), but this is ignored for now. If the command line flag is not specified, old behaviour still applies, so this change is completely backward compatible.
* | Fix rubocop offense introduced in 161ed37bogdanvlviv2018-07-081-1/+1
|/ | | | | | | | | | | | | | We prefer double quotes over single quotes. Fixes: ``` railties/lib/rails/commands/server/server_command.rb:279:39: C: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoi d extra backslashes for escaping. original_options.concat [ '-u', using ] ``` Related to 161ed37d7120e1f391eed19e49a3390e53e4fe91
* Don't balloon @original_options with --restart on restart.Kasper Timm Hansen2018-07-071-1/+1
| | | | | | | | Our restart_command would pass in `--restart` which means that if the @original_options already contains --restart it would keep getting another --restart appended. Nothing here that would break the bank, but just a nicety.
* Don't show unneeded deprecation warning on server restart.Kasper Timm Hansen2018-07-071-8/+14
| | | | | | | | | | | | | | | | | If booting a server via `rails s -u puma`, we'd convert the option to a `using` positional. When using `rails restart` our `restart_command` would the option converted to the using positional and put that in the restart command. Thus we'd show users deprecation warnings for our own code. Fix that by converting a passed positional to an option instead. Also: fix initialize method signature. The local_options are an array, not a hash. But don't even bother assigning defaults as Thor passes them in.
* Remove restart_command leftover from switching to Thor options.Kasper Timm Hansen2018-07-071-4/+0
| | | | | | | | | | | Ref: https://github.com/rails/rails/commit/654704247eba742e139cfaa8d1385f13605d9e12 Before the commit we had a restart_command in Rails::Server. But after there's another one in Rails::ServerCommand. The command version of the method is the right one as it's used in server_options. Give the leftover method the boot.
* Use only snake cased symbols in commands.Kasper Timm Hansen2018-07-071-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mixing strings and symbols seems aesthetically less than ideal. We can also use underscores just fine. Thor converts them to dashes for the CLI and it makes access in Ruby code nicer. Here's the `server --help` output after this change: ``` Usage: rails server [thin/puma/webrick] [options] Options: -p, [--port=port] # Runs Rails on the specified port - defaults to 3000. -b, [--binding=IP] # Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'. -c, [--config=file] # Uses a custom rackup configuration. # Default: config.ru -d, [--daemon], [--no-daemon] # Runs server as a Daemon. -e, [--environment=name] # Specifies the environment to run this server under (development/test/production). -u, [--using=name] # Specifies the Rack server used to run the application (thin/puma/webrick). -P, [--pid=PID] # Specifies the PID file. # Default: tmp/pids/server.pid -C, [--dev-caching], [--no-dev-caching] # Specifies whether to perform caching in development. [--early-hints], [--no-early-hints] # Enables HTTP/2 early hints. ``` See? Quite dashing ✨
* Remove unused requireyuuji.yaginuma2018-06-181-1/+0
| | | | `optparse` is unused since #26977.
* Remove unnecessary testyuuji.yaginuma2018-06-031-2/+2
| | | | | Since #32289, `Spellchecker.suggest` returns only one value, multiple suggestions not output.
* Deprecate support for using `HOST` environment to specify server IP (#32540)Yuji Yaginuma2018-04-161-2/+12
| | | | | | | | | | | | At SuSE, `$HOST` is set by default and is equal to `$HOSTNAME`. https://www.suse.com/documentation/sled11/book_sle_admin/data/sec_adm_variables.html Therefore, by default, it binds to hostname instead of `localhost`. This seems not to be appropriate as default behavior. In order to avoid the name of the environment variable being used, I changed the environment variable from `HOST` to `BINDING`. Fixes #29516.
* Use `did_you_mean` spell checker for option suggestionsGenadi Samokovarov2018-03-231-2/+2
| | | | | | | | | | | Now that we require Ruby over `2.3`, we can replace the current suggestion methods we have with tooling from the `did_you_mean` gem. There is a small user visible change and this is that we now offer a single suggestion for misspelled options. We are suggesting fixes during generator invocation and during a mistyped rails server rack handler. In both cases, if we don't make a proper prediction on the first match, we won't do so in the second or third one, so in my mind, this is okay.
* Do not show unnecessary message during server startupyuuji.yaginuma2018-03-101-6/+5
| | | | | | | | | | | | | | | | | | | | Currently, `Exiting` is showed during server startup. ``` ./bin/rails s => Booting Puma => Rails 6.0.0.alpha application starting in development => Run `rails server --help` for more startup options Exiting Puma starting in single mode... * Version 3.11.2 (ruby 2.5.0-p0), codename: Love Song ``` This is because processing at server stop is passed as a block, and `Rack::Serve#start` receives a block and executes it during startup processing. https://github.com/rack/rack/blob/50db1ffdf8b98503fb7c6e6648622b5d7d78d58e/lib/rack/server.rb#L258 In order to avoid this, stop processing is passed as argument.
* Fix "NameError: undefined local variable or method `host'"yuuji.yaginuma2018-03-051-1/+1
| | | | The `host` and `port` can't use this context.
* Introduce explicit rails server handler optionGenadi Samokovarov2018-03-041-16/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I mistype `rails server production` instead of `rails server -e production` expecting to lunch a server in the production environment all the time. However, the signature of `rails server --help` is: ``` Usage: rails server [puma, thin etc] [options] ``` This means that the `production` argument is being interpreted as a Rack server handler like Puma, Thin or Unicorn. Should we argue for the `rails server production`? I'm not sure of the reasons, but the `rails console production` behavior was deprecated in: https://github.com/rails/rails/pull/29358, so parity with the existing `rails console production` usage may not hold anymore. In any case, this PR introduces an explicit option for the Rack servers configuration. The option is called `--using` (or `-u` for short) to avoid the `rails server --server` tantrum. The new interface of `rails server` is: ``` Usage: rails server [using] [options] Options: -p, [--port=port] # Runs Rails on the specified port - defaults to 3000. -b, [--binding=IP] # Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'. -c, [--config=file] # Uses a custom rackup configuration. # Default: config.ru -d, [--daemon], [--no-daemon] # Runs server as a Daemon. -e, [--environment=name] # Specifies the environment to run this server under (development/test/production). -u, [--using=name] # Specifies the Rack server used to run the application (thin/puma/webrick). -P, [--pid=PID] # Specifies the PID file. # Default: tmp/pids/server.pid -C, [--dev-caching], [--no-dev-caching] # Specifies whether to perform caching in development. [--early-hints], [--no-early-hints] # Enables HTTP/2 early hints. ``` As a bonus, if you mistype the server to use, you'll get an auto-correction message: ``` $ rails s tin Could not find handler "tin". Maybe you meant "thin" or "cgi"? Run `rails server --help` for more options. ```
* Improve the deprecation message for using subclass of Rails::Application to ↵Prathamesh Sonpatki2018-01-071-1/+1
| | | | start the Rails server
* [Railties] require_relative => requireAkira Matsuda2017-10-211-1/+1
| | | | This basically reverts 618268b4b9382f4bcf004a945fe2d85c0bd03e32
* Implement H2 Early Hints for Railseileencodes2017-10-041-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When puma/puma#1403 is merged Puma will support the Early Hints status code for sending assets before a request has finished. While the Early Hints spec is still in draft, this PR prepares Rails to allowing this status code. If the proxy server supports Early Hints, it will send H2 pushes to the client. This PR adds a method for setting Early Hints Link headers via Rails, and also automatically sends Early Hints if supported from the `stylesheet_link_tag` and the `javascript_include_tag`. Once puma supports Early Hints the `--early-hints` argument can be passed to the server to enable this or set in the puma config with `early_hints(true)`. Note that for Early Hints to work in the browser the requirements are 1) a proxy that can handle H2, and 2) HTTPS. To start the server with Early Hints enabled pass `--early-hints` to `rails s`. This has been verified to work with h2o, Puma, and Rails with Chrome. The commit adds a new option to the rails server to enable early hints for Puma. Early Hints spec: https://tools.ietf.org/html/draft-ietf-httpbis-early-hints-04 [Eileen M. Uchitelle, Aaron Patterson]
* Make `restart` and `dev:cache` tasks work when customizing pid file pathyuuji.yaginuma2017-08-211-1/+7
| | | | | | | | | | 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
* Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-141-0/+2
|
* Deprecate support of older `config.ru`yuuji.yaginuma2017-08-081-1/+8
| | | | | | | | Since Rails 4.0, `config.ru` generated by default uses instances of `Rails.application`. Therefore, I think that it is good to deprecate the old behavior. Related: #9669
* Do not show URL in boot info when using Pumayuuji.yaginuma2017-07-241-2/+6
| | | | | | | | | | | Puma has its own configuration file(e.g. `config/puma.rb`). Can define a port and a URL to bind in the configuration file. Therefore, on Rails side, can not grasp which URI to bind finally. Because of that, it may show a URL different from the actually bound URL, so I think that it is better not to show it. Fixes #29880
* [Railties] require => require_relativeAkira Matsuda2017-07-011-1/+1
|
* Correctly set user_supplied_options when there is no whitespace in option ↵yuuji.yaginuma2017-05-241-2/+9
| | | | | | | | | | specification Current `user_supplied_options` method can not set the value correctly if there is no space between option and value (e.g., `-p9000`). This makes it possible to set the value correctly in the case like the above. Fixes #29138
* CLI arg `--port` has precedence over env `PORT`.koshigoe2017-05-011-2/+3
|
* CLI arg "host" has precedence over ENV var "host"Jon Moss2017-03-211-2/+4
| | | | | | | This is a regression from when the server command switched to its own argument parser, as opposed to Rack's. Rack's argument parser, when provided with a "host" argument, gives that value precedence over environment variables.
* `HOST` must be all capital lettersyuuji.yaginuma2017-03-011-1/+1
| | | | Ref: https://github.com/rails/rails/blob/master/railties/lib/rails/commands/server/server_command.rb#L194
* Set correct host except development environmentyuuji.yaginuma2017-02-271-3/+7
| | | | | | | | Currently `localhost` is used for the default host in all environments. But up to Rails 5.0, `0.0.0.0` is used except for development. So fixed to use the same value as 5.0. Fixes #28184
* [close #24435] Send user_supplied_options to serverschneems2017-02-241-11/+44
| | | | | | | | | | | | | | | | | | Currently when Puma gets a `:Port` it doesn't know if it is Rails' default port or if it is one that is specified by a user. Because of this it assumes that the port passed in is always a user defined port and therefor 3000 always "wins" even if you specify `port` inside of the `config/puma.rb` file when booting your server with `rails s`. The fix is to record the options that are explicitly passed in from the user and pass those to the Puma server (or all servers really). Puma then has enough information to know when `:Port` is the default and when it is user defined. I went ahead and did this for all values rails server exposes as server side options for completeness. The hardest thing was converting the input say `-p` or `--port` into the appropriate "name", in this case `Port`. There may be a more straightforward way to do this with Thor, but I'm not an expert here. Move logic for parsing user options to method Better variable name for iteration Explicitly test `--port` user input ✂️ Update array if environment variables are used
* make all rails commands work in engineyuuji.yaginuma2017-01-091-2/+6
| | | | | | | | Currently, all rails commands can be executed in engine, but `server`, `console`, `dbconsole` and `runner` do not work. This make all rails commands work in engine. Related to #22588
* use Thor option parser in server commands parseyuuji.yaginuma2016-12-241-54/+67
| | | | | | | | | | The `ServerCommand` inherits Thor, but currently does not use Thor option parser. Therefore, if leave the argument of Thor as it is, it becomes an error by the argument checking of Thor. To avoid it, to use the Thor option parser instead of reimplementing it. Fixes #26964
* Hide commands from API site.Kasper Timm Hansen2016-10-281-2/+2
| | | | | They're just barren on the site and confure more than guide, instead rely on the built in --help to guide users.
* remove `mongrel` once againyuuji.yaginuma2016-09-291-1/+1
| | | | `mongrel` was removed in #26408. But have back accidentally in #26414.
* Apply Rafaels review fixes.Kasper Timm Hansen2016-09-251-1/+3
|
* Per Dr. Eileen's orders :)Kasper Timm Hansen2016-09-251-1/+0
| | | | Prescribed some review fixes for myself!
* Initial command structure.Kasper Timm Hansen2016-09-251-0/+159