-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add time window #64
Comments
@stanim I have this feature in mind since long time, but actually I have not time to implement it, so I share with you my idea in case you want to send a PR: MAINTENANCE_MODE_SCHEDULE={
'mon': {
'on': '03:00',
'off': '03:30',
},
'tue': {
'on': '14:30',
'off': '14:45',
},
# for each day, or use * for all days
} I would add support to a new setting like this one, what do you think about it? |
The problem is that the business needs to be able to configure this from a webview. So Django settings are no solution, as settings are supposed to be immutable. Would it be possible to store the settings in the maintenance lock file? |
I understand your needs, but it seems a specific case. The maintenance state file is not for this, you should write a custom state backend that return values based on the configuration done in the webview. |
I use https://django-constance.readthedocs.io/en/latest/ for configuring stuff like this. For example: CONSTANCE_CONFIG = {
"MAINTENANCE_ENABLED": (False, "Maintenance mode is enabled", bool),
"MAINTENANCE_END": (datetime(2023, 11, 7, 11), "Maintenance mode end", datetime),
} So you just need to implement MAINTENANCE_MODE_STATE_BACKEND as mentioned before to use this setting. @fabiocaccamo Maybe you want to add this backend to your package, so people can choose the bundled backend if they use Constance? |
@miklevtsov of which backend are you talking about? I think that this should be managed at settings level as described here #66 (comment) and also that any backend implementation would be too specific. |
@fabiocaccamo can i contribute to this ?? |
@Pavankumardontha sure, but please read my prev comment. |
@fabiocaccamo i have read the discussions. I feel webview is not possible for now since we need db and you want to keep it db free. What can i do more to contribute to this ? Any suggestion from your end ? |
@Pavankumardontha my idea is to add a new # or this to schedule maintenance every day:
MAINTENANCE_MODE_SCHEDULE = {
'*': {'start':'01:00', 'end':'02:00'},
}
# or this to specify days
MAINTENANCE_MODE_SCHEDULE = {
'sun': {'start':'01:00', 'end':'02:00'},
'mon': None,
'tue': None,
'wed': {'start':'01:00', 'end':'02:00'},
'thu': None,
'fri': None,
'sat': None,
} Then you only need to update this function: An alternative solution that is already supported, is to use cronjobs for calling the managements commands at specific days/hours. |
The business want to be able to specify a time window (start time and end time) in which the website turns automatically the website on and off. What would be the best method? Maybe a new setting which defines a function which is called in
need_maintenance_response
?Would you accept a pull request for this?
The text was updated successfully, but these errors were encountered: