Skip to content

Commit e8c5a72

Browse files
Update README.md
1 parent 60193fb commit e8c5a72

File tree

1 file changed

+67
-49
lines changed

1 file changed

+67
-49
lines changed

README.md

Lines changed: 67 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -55,73 +55,38 @@ This package requires Laravel 10 or 11.
5555

5656
# Installation
5757

58-
(1) Require the package using Composer
58+
Require the package using Composer
5959

6060
```bash
6161
composer require stackkit/laravel-google-cloud-scheduler
6262
```
6363

64-
(2) Define the `STACKKIT_CLOUD_SCHEDULER_APP_URL` environment variable. This should be the URL defined in the `URL` field of your Cloud Scheduler job.
64+
Define the `STACKKIT_CLOUD_SCHEDULER_APP_URL` environment variable. This should be the URL defined in the `URL` field of your Cloud Scheduler job.
6565

6666
```
6767
STACKKIT_CLOUD_SCHEDULER_APP_URL=https://yourdomainname.com/cloud-scheduler-job
6868
```
6969

70-
(3) Optional: whitelist route for maintenance mode
70+
Optional, but highly recommended: server configuration
7171

72+
Ensure the webserver won't terminate the request prematurely. Configure the correct timeout settings.
7273

73-
If you want to allow jobs to keep running if the application is down (`php artisan down`), update the following:
74-
75-
<details>
76-
<summary>Laravel 11</summary>
74+
```nginx
75+
server {
76+
# other server configuration ...
7777
78-
```php
79-
return Application::configure(basePath: dirname(__DIR__))
80-
->withRouting(
81-
web: __DIR__ . '/../routes/web.php',
82-
commands: __DIR__ . '/../routes/console.php',
83-
health: '/up',
84-
)
85-
->withMiddleware(function (Middleware $middleware) {
86-
$middleware->preventRequestsDuringMaintenance(
87-
except: [
88-
'/cloud-scheduler-job',
89-
],
90-
);
91-
})
92-
->withExceptions(function (Exceptions $exceptions) {
93-
//
94-
})->create();
95-
96-
97-
```
98-
</details>
99-
<details>
100-
<summary>Laravel 10</summary>
101-
102-
```php
103-
<?php
104-
105-
namespace App\Http\Middleware;
106-
107-
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
78+
location /cloud-scheduler-job {
79+
proxy_connect_timeout 600s;
80+
proxy_read_timeout 600s;
81+
fastcgi_read_timeout 600s;
82+
}
10883
109-
class PreventRequestsDuringMaintenance extends Middleware
110-
{
111-
/**
112-
* The URIs that should be reachable while maintenance mode is enabled.
113-
*
114-
* @var array
115-
*/
116-
protected $except = [
117-
+ '/cloud-scheduler-job',
118-
];
84+
# other locations and server configuration ...
11985
}
12086
12187
```
122-
</details>
12388

124-
(4) Optional: set application `RUNNING_IN_CONSOLE` (highly recommended)
89+
Optional, but highly recommended: set application `RUNNING_IN_CONSOLE`
12590

12691
Some Laravel service providers only register their commands if the application is being accessed through the command line (Artisan). Because we are calling Laravel scheduler from a HTTP call, that means some commands may never register, such as the Laravel Scout command:
12792

@@ -207,6 +172,59 @@ $app = new Illuminate\Foundation\Application(
207172
```
208173
</details>
209174

175+
Optional: whitelist route for maintenance mode
176+
177+
If you want to allow jobs to keep running if the application is down (`php artisan down`), update the following:
178+
179+
<details>
180+
<summary>Laravel 11</summary>
181+
182+
```php
183+
return Application::configure(basePath: dirname(__DIR__))
184+
->withRouting(
185+
web: __DIR__ . '/../routes/web.php',
186+
commands: __DIR__ . '/../routes/console.php',
187+
health: '/up',
188+
)
189+
->withMiddleware(function (Middleware $middleware) {
190+
$middleware->preventRequestsDuringMaintenance(
191+
except: [
192+
'/cloud-scheduler-job',
193+
],
194+
);
195+
})
196+
->withExceptions(function (Exceptions $exceptions) {
197+
//
198+
})->create();
199+
200+
201+
```
202+
</details>
203+
<details>
204+
<summary>Laravel 10</summary>
205+
206+
```php
207+
<?php
208+
209+
namespace App\Http\Middleware;
210+
211+
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
212+
213+
class PreventRequestsDuringMaintenance extends Middleware
214+
{
215+
/**
216+
* The URIs that should be reachable while maintenance mode is enabled.
217+
*
218+
* @var array
219+
*/
220+
protected $except = [
221+
+ '/cloud-scheduler-job',
222+
];
223+
}
224+
225+
```
226+
</details>
227+
210228
# Cloud Scheduler Example
211229

212230
Here is an example job that will run `php artisan schedule:run` every minute.

0 commit comments

Comments
 (0)