diff --git a/deployment.md b/deployment.md index 292e0be022..40c3d2b3d4 100644 --- a/deployment.md +++ b/deployment.md @@ -11,6 +11,7 @@ - [Caching Events](#caching-events) - [Caching Routes](#optimizing-route-loading) - [Caching Views](#optimizing-view-loading) +- [Reloading Services](#reloading-services) - [Debug Mode](#debug-mode) - [The Health Route](#the-health-route) - [Deploying With Laravel Cloud or Forge](#deploying-with-cloud-or-forge) @@ -168,6 +169,20 @@ php artisan view:cache This command precompiles all your Blade views so they are not compiled on demand, improving the performance of each request that returns a view. + +## Reloading Services + +> [!NOTE] +> When deploying to [Laravel Cloud](https://cloud.laravel.com), it is not necessary to use the `reload` command, as gracefully reloading of all services is handled automatically. + +After deploying a new version of your application, any long-running services such as queue workers, Laravel Reverb, or Laravel Octane should be reloaded / restarted to use the new code. Laravel provides a single `reload` Artisan command that will terminate these services: + +```shell +php artisan reload +``` + +If you are not using [Laravel Cloud](https://cloud.laravel.com), you should manually configure a process monitor that can detect when your reloadable processes exit and automatically restart them. + ## Debug Mode diff --git a/packages.md b/packages.md index 3fb9dd306f..0dd89623c3 100644 --- a/packages.md +++ b/packages.md @@ -14,6 +14,7 @@ - ["About" Artisan Command](#about-artisan-command) - [Commands](#commands) - [Optimize Commands](#optimize-commands) + - [Reload Commands](#reload-commands) - [Public Assets](#public-assets) - [Publishing File Groups](#publishing-file-groups) @@ -390,6 +391,23 @@ public function boot(): void } ``` + +### Reload Commands + +Laravel's [reload command](/docs/{{version}}/deployment#reloading-services) terminates any running services so they can be automatically restarted by a system process monitor. Using the `reloads` method, you may register your package's own Artisan commands that should be invoked when the `reload` command is executed: + +```php +/** + * Bootstrap any package services. + */ +public function boot(): void +{ + if ($this->app->runningInConsole()) { + $this->reloads('package:reload'); + } +} +``` + ## Public Assets