Skip to content

Commit

Permalink
README improved for queues
Browse files Browse the repository at this point in the history
  • Loading branch information
gecche committed May 22, 2019
1 parent adbeb91 commit 78c03a3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## 1.1.3 - 2019-05-22
### Changed
- README.md improved with queue example

## 1.1.2 - 2019-03-23
### Added
- Added new domain:list artisan command displaying info of installed domains
Expand All @@ -22,3 +26,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
[Unreleased]: https://github.com/gecche/laravel-multidomain/compare/v1.1.1...HEAD
[1.1.1]: https://github.com/gecche/laravel-multidomain/compare/v1.1.0...v1.1.1
[1.1.2]: https://github.com/gecche/laravel-multidomain/compare/v1.1.1...v1.1.2
[1.1.3]: https://github.com/gecche/laravel-multidomain/compare/v1.1.2...v1.1.3
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ In addition, within the standard `storage` folder, two new folders have been cre
In particular, the folder structure within the new storage folders can be customized
in the `domain.php` config file.

#### Distinguishing between HTTP domains
#### Distinguishing between HTTP domains in web pages

For each HTTP request received by the application, the specific environment file is
loaded and the specific storage folder is used.
Expand All @@ -119,11 +119,49 @@ For each HTTP request received by the application, the specific environment file
The detection of the right HTTP domain is done by using the `$_SERVER['SERVER_NAME']`
PHP variable.

In order to distinguishing between domains use artisan commands (including queue stuff),
each artisan command accepts now a new option `domain`. E.g.:
#### Using multi domains in artisan commands

In order to distinguishing between domains, each artisan command accepts now a new option `domain`. E.g.:
```
php artisan list --domain=site1.com
```
The command will use the corresponding domain settings.

#### About queues

As for the others artisan commands, also `queue:work` and `queue:listen` commands have been updated
to accept a new `domain` option.
```
php artisan queue:work --domain=site1.com
```
As usual the above command will use the corresponding domain settings.
Keep in mind that if, for example, you are using the `database` driver and you have two domains,
namely `site1.com` and `site2.com`, sharing the same db, you should use two distinct queues if you want
to manage separately the jobs of each domain.
In particular, you could
- put in your .env files a default queue for each domain, e.g.
`QUEUE_DEFAULT=default1` for site1.com and `QUEUE_DEFAULT=default2` for site2.com
- update the `queue.php` config file by changing the default queue accordingly:
```
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => env('QUEUE_DEFAULT','default'),
'retry_after' => 90,
],
```
- finally launch two distinct workers
```
php artisan queue:work --domain=site1.com --queue=default1
```
and
```
php artisan queue:work --domain=site1.com --queue=default2
```

Obviously, the same can be done for each other queue driver apart from the `sync` driver.


#### `domain.remove` command
The `domain:remove` command simply removes the specified HTTP domain from the
Expand Down

0 comments on commit 78c03a3

Please sign in to comment.