forked from rubocop/rubocop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The integrated daemon feature is described in the docs/modules/ROOT/pages/usage/server.adoc included in this PR. ## Daemon options ```console % bundle exec rubocop --help (snip) Server Options: --[no-]server If the daemon process has not started yet, start the server process and execute inspection with server. Default is false. You can specify the daemon host and port with the $RUBOCOP_SERVER_HOST and the $RUBOCOP_SERVER_PORT environment variables. --restart-server Restart server process. --start-server Start server process. --stop-server Stop server process. --server-status Show server status. ``` The daemon mode `--daemon` is disabled by default because it is not yet stable as an integrated feature. ## Design note `RuboCop::Daemon::CLI`'s daemon options are not integrated into `RuboCop::CLI` and `RuboCop::Options`. Because `RuboCop::CLI` and `RuboCop::Options` classes have many dependencies and require the rubocop client (`exe/rubocop`) to make unnecessary `require '...'`. It's important to be lightweight because the daemon mode runs fast, so this design decided to have command line daemon options own (lightweight) option parse logic. And this design only exe/rubocop and lib/rubocop/options.rb files have changed, So almost all daemon code keep independent. NOTE: This feature cannot be used on JRuby and Windows that do not support fork.
- Loading branch information
Showing
35 changed files
with
795 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
require 'bundler/setup' | ||
require 'irb' | ||
require 'rubocop' | ||
require 'rubocop/server' | ||
|
||
ARGV.clear | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#10706](https://github.com/rubocop/rubocop/pull/10706): Integrate rubocop-daemon to add server options. ([@koic][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
ba | ||
creat | ||
enviromnent | ||
filetest | ||
fo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
= Server Mode | ||
|
||
You can reduce the RuboCop boot time by using the `--server` option. | ||
|
||
The server option speeds up the launch of the `rubocop` command by serverizing | ||
the process that loaded the RuboCop runtime production files (i.e. `require 'rubocop'`). | ||
|
||
NOTE: The feature cannot be used on JRuby and Windows that do not support fork. | ||
|
||
== Run with Server | ||
|
||
There are two ways to enable server. | ||
|
||
- `rubocop --server` ... If server process has not started yet, | ||
start server process and execute inspection with server. | ||
- `rubocop --start-server` ... Just start server process. | ||
|
||
When server is started, it outputs the host and port. | ||
|
||
```console | ||
% rubocop --start-server | ||
RuboCop server starting on 127.0.0.1:55772. | ||
``` | ||
|
||
NOTE: The `rubocop` command is executed using server process if server is started. | ||
Whenever server process is not running, it will load the RuboCop runtime files and execute. | ||
(same behavior as 1.30 and lower) | ||
|
||
If server is already running, just display the PID. The new server will not start. | ||
|
||
```console | ||
% rubocop --start-server | ||
RuboCop server (16060) is already running. | ||
``` | ||
|
||
A started server process name is `rubocop --server` with project directory path. | ||
|
||
```console | ||
% ps aux | grep 'rubocop --server' | ||
user 16060 0.0 0.0 5078568 2264 ?? S 7:54AM 0:00.00 rubocop --server /Users/user/src/github.com/rubocop/rubocop | ||
user 16337 0.0 0.0 5331560 2396 ?? S 23:51PM 0:00.00 rubocop --server /Users/user/src/github.com/rubocop/rubocop-rails | ||
``` | ||
|
||
== Restart Server | ||
|
||
The started server does not reload the configuration file. | ||
You will need to restart server when you upgrade RuboCop or change | ||
the RuboCop configuration. | ||
|
||
```console | ||
% rubocop --restart-server | ||
RuboCop server starting on 127.0.0.1:55822. | ||
``` | ||
|
||
This may be supported so that no reboot is required in future. | ||
|
||
== Command Line Options | ||
|
||
These are options for server operations. | ||
|
||
* `--server` ... If server process has not started yet, start the | ||
server process and execute inspection with server. You can specify | ||
the server host and port with the $RUBOCOP_SERVER_HOST and | ||
the $RUBOCOP_SERVER_PORT environment variables. | ||
* `--no-server` ... If server process has been started, stop the | ||
server process and execute inspection with server. | ||
* `--restart-server` ... Restart server process. | ||
* `--start-server` ... Start server process. | ||
* `--stop-server` ... Stop server process. | ||
* `--server-status` ... Show server status. | ||
|
||
== Environment Variables | ||
|
||
You can change the startup host and port of server process with | ||
environment variables. | ||
|
||
* `$RUBOCOP_SERVER_HOST` | ||
* `$RUBOCOP_SERVER_PORT` | ||
|
||
The following is an example: | ||
|
||
```console | ||
% RUBOCOP_SERVER_PORT=98989 rubocop --start-server | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.