-
Notifications
You must be signed in to change notification settings - Fork 106
feat: [#546] artisan command up and down to set website Maintenance mode #1198
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
base: master
Are you sure you want to change the base?
feat: [#546] artisan command up and down to set website Maintenance mode #1198
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1198 +/- ##
==========================================
- Coverage 68.55% 67.97% -0.58%
==========================================
Files 228 235 +7
Lines 14588 14762 +174
==========================================
+ Hits 10001 10035 +34
- Misses 4229 4367 +138
- Partials 358 360 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This is a fantastic PR with a very useful addition to the framework! 🎉 I have a suggestion: how about allowing an optional |
|
|
||
| func (s *DownCommandTestSuite) TestHandle() { | ||
| app := mocksfoundation.NewApplication(s.T()) | ||
| tmpfile := filepath.Join(os.TempDir(), "/down") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In unit tests, use t.TempDir() instead of os.TempDir().
t.TempDir() is preferred in unit tests because it creates a unique temporary directory for each test and automatically cleans it up after the test finishes. This helps prevent conflicts and side effects between tests, making your tests safer and more reliable.
|
Please fix the windows CI. |
|
Thanks, great job 👍 Could add some related screenshots in the PR description? |
| func CheckForMaintenance() http.Middleware { | ||
| return func(ctx http.Context) { | ||
| if file.Exists(path.Storage("framework/down")) { | ||
| ctx.Request().AbortWithStatus(http.StatusServiceUnavailable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ctx.Request().AbortWithStatus(http.StatusServiceUnavailable) | |
| ctx.Request().Abort(http.StatusServiceUnavailable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
foundation/console/down_command.go
Outdated
|
|
||
| // Handle Execute the console command. | ||
| func (r *DownCommand) Handle(ctx console.Context) error { | ||
| path := r.app.StoragePath("framework/down") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| path := r.app.StoragePath("framework/down") | |
| path := r.app.StoragePath("framework/maintenance") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
foundation/console/down_command.go
Outdated
|
|
||
| // Extend The console command extend. | ||
| func (r *DownCommand) Extend() command.Extend { | ||
| return command.Extend{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is reason still required in this case? @almas-x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can implement those options @hwbrzzl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compared to Laravel, the current implementation of reason is indeed a bit limited. I think we can refer to Laravel's implementation and support all the options in your screenshot except for the two that are crossed out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. What should be the response would be when no --render option is provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning the current logic should be fine.
3479a4b to
b70c346
Compare

📑 Description
This PR adds two Artisan commands
The
downcommands creates a temporary file in the framework storage folderThe
upcommands removes that file if existsThere is an another middleware
CheckForMaintenance, that checks for the file.It returns the request with
503status code if the file exists else allow the request to passthrough.Closes goravel/goravel#546
✅ Checks