Skip to content

Commit 8c7e553

Browse files
authored
Merge pull request rails#53284 from kabirpathak/update-rails-runner-documentation
[ci skip] Document `--skip-executor` option for Rails Runner
2 parents 2f6bfb3 + fd47f78 commit 8c7e553

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

guides/source/command_line.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,22 @@ You can even execute ruby code written in a file with runner.
478478
$ bin/rails runner lib/code_to_be_run.rb
479479
```
480480
481+
By default, `rails runner` scripts are automatically wrapped with the Rails Executor, which helps report uncaught exceptions for tasks like cron jobs.
482+
483+
Therefore, executing `rails runner lib/long_running_scripts.rb` is functionally equivalent to the following:
484+
485+
```ruby
486+
Rails.application.executor.wrap do
487+
# executes code inside lib/long_running_scripts.rb
488+
end
489+
```
490+
491+
You can opt out of this behaviour by using the `--skip-executor` option.
492+
493+
```bash
494+
$ bin/rails runner --skip-executor lib/long_running_script.rb
495+
```
496+
481497
### `bin/rails destroy`
482498
483499
Think of `destroy` as the opposite of `generate`. It'll figure out what generate did, and undo it.

0 commit comments

Comments
 (0)