Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Document tenants:up and tenants:down commands #214

Closed
lukinovec opened this issue Oct 5, 2022 · 8 comments
Closed

[4.x] Document tenants:up and tenants:down commands #214

lukinovec opened this issue Oct 5, 2022 · 8 comments

Comments

@lukinovec
Copy link
Collaborator

lukinovec commented Oct 5, 2022

I wrote docs for the new Up/Down commands. @stancl, there are comments in the Down command saying some Laravel features are not available with tenants because of storing the data in the tenant database. I think we should document that, but what exactly are the limitations?

EDIT: updated to include info from this comment

The documentation:

Maintenance mode commands (tenant-aware)

Note: Ensure your tenant model uses the MaintenanceMode trait and casts the maintenance_mode property to array before using the Up and Down commands.

This package provides commands for putting tenants into maintenance mode (tenants:down), and out of maintenance mode (tenants:up).

Tenant databases are used for storing maintenance mode information (maintenance_mode in tenant's data column). This cannot be changed by setting the driver using the app.maintenance.driver config key.

The tenants:down command accepts the same options as Laravel's down command, except for --render.

Visit the Laravel documentation for more information about maintenance mode with the mentioned limitations in mind.

php artisan tenants:down

Tenants are now in maintenance mode.

php artisan tenants:up

Tenants are now out of maintenance mode.
@stancl
Copy link
Owner

stancl commented Oct 5, 2022

No idea about that comment. Can you open the file in the repo and click on "Blame" to find which commit added that?

@lukinovec
Copy link
Collaborator Author

lukinovec commented Oct 5, 2022

@stancl
Copy link
Owner

stancl commented Oct 5, 2022

Ah I see, I first thought this is related to migrations (I was reading this on mobile) but this is the maintenance mode. I see what he meant there. By default, Laravel stores maintenance mode details in a file (somewhere in storage_path(), or in storage/framework/... I believe). We store them on each tenant, so we use the tenants table.

Perhaps @stein-j could explain what exact features are not available? Maybe we discussed this in the original PR that I closed, so @lukinovec you could try checking there.

@stein-j
Copy link
Contributor

stein-j commented Oct 5, 2022

I must say, my comment is not very helpful, I don't even remember what I meant by "The base down command is heavily used."

Okay, from what I remember there are two things:

  1. You can "render" a page, so that Laravel don't even nee to boot and instantly return a static html page (Laravel Doc). This is done in the first file that is loaded [public/index.php] (https://github.com/laravel/laravel/blob/5138bc36dbc884098ea68942e805b2267e7a627f/public/index.php#L19). But with the tenants, the data is stored in the database, so it has to boot Laravel. So the option --render is not available, which I think is fine because if you need to down a single tenant, you probably aren't working on the server at the same time but simply denying access temporally.

  2. The second issue is more recent, because Laravel has now implemented drivers for the maintenance mode, so you can decide if you want to store the information that your app is in maintenance mode in the file or in the cache. (mostly useful when using load balancers). So if you change app.maintenance.driver to cache, putting a tenant into maintenance mode will still be stored in the database. Thought, this feature could be replicated in this package.

@lukinovec
Copy link
Collaborator Author

Thank you for the info, I checked out the PR that adds the commands, and it seems the only discussed limitations are the ones you mention here.

Related comments:
archtechx/tenancy#761 (comment) – "all parameters can be recreated except for render because this allows to return a response even before Laravel is initialised (which means, before the package is also initialised)"
archtechx/tenancy#761 (comment) – "It might be important to mention in the documentation that the maintenance mode doesn't uses the driver from the config file"

@lukinovec
Copy link
Collaborator Author

Updated the documentation @stancl

@stein-j
Copy link
Contributor

stein-j commented Oct 7, 2022

I've just made a PR so implement tenancy maintenance mode drivers: archtechx/tenancy#967.

Note: This doesn't uses the same config parameter app.maintenance.driver, but has a replicated config in the tenancy file tenancy.maintenance.driver.

Laravel has two drivers file & cache, whereas Tenancy would have database & cache.

I know you just changed the documentation, if this PR is merged you'll need to update it again 😆

@stancl
Copy link
Owner

stancl commented Oct 9, 2022

Regarding what @stein-j wrote #214 (comment), I think the first issue is fine because the maintenance mode is tenant-specific. And the second issue I addressed in the PR — it's probably not pursuing.

So this looks good now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants