Disable AP Scheduler while performing maintenance

This commit is contained in:
sabaimran
2024-05-30 08:02:59 +05:30
parent 4aac84e1c1
commit 2076543e32
3 changed files with 57 additions and 13 deletions

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="-0.5 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.75 15C8.13071 15 9.25 13.8807 9.25 12.5C9.25 11.1193 8.13071 10 6.75 10C5.36929 10 4.25 11.1193 4.25 12.5C4.25 13.8807 5.36929 15 6.75 15Z" stroke="#0F0F0F" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M17.25 8C18.6307 8 19.75 6.88071 19.75 5.5C19.75 4.11929 18.6307 3 17.25 3C15.8693 3 14.75 4.11929 14.75 5.5C14.75 6.88071 15.8693 8 17.25 8Z" stroke="#0F0F0F" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M17.25 22C18.6307 22 19.75 20.8807 19.75 19.5C19.75 18.1193 18.6307 17 17.25 17C15.8693 17 14.75 18.1193 14.75 19.5C14.75 20.8807 15.8693 22 17.25 22Z" stroke="#0F0F0F" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M13.49 17.05L10.45 15.06" stroke="#0F0F0F" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M13.48 7.96001L10.46 9.94001" stroke="#0F0F0F" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -2,6 +2,16 @@
{% block content %}
<div class="page">
<div class="section">
<div id="maintenance-notice">
<div class="urgent-notice">
<p>
Hold up! Our Automations are taking a well-deserved break for some maintenance magic. They'll be back in action soon, better than ever. Thanks for your patience!
</p>
<div>
<a class="maintenance-action" href="/">Back to Chat</a>
</div>
</div>
</div>
<h2 class="section-title">
<img class="card-icon" src="/static/assets/icons/automation.svg?v={{ khoj_version }}" alt="Automate">
<span class="card-title-text">Automate (Preview)</span>
@@ -208,6 +218,32 @@
grid-gap: 8px;
}
div#maintenance-notice {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 2;
background-image: linear-gradient(to bottom, rgba(250, 130, 130, 0.8), rgba(255, 165, 0, 0.8));
}
a.maintenance-action{
color: white;
text-decoration: none;
}
div.urgent-notice p,
div.urgent-notice a {
font-size: 24px;
font-weight: bold;
padding: 20px;
text-align: left;
}
div.subject-wrapper p {
margin: 0;
}
@@ -237,7 +273,7 @@
}
</style>
<script>
<!-- <script>
function deleteAutomation(automationId) {
const AutomationList = document.getElementById("automations");
fetch(`/api/automation?automation_id=${automationId}`, {
@@ -879,5 +915,5 @@
document.getElementById("automations").insertBefore(automationEl, document.getElementById("automations").firstChild);
setupScheduleViewListener("* * * * *", placeholderId);
})
</script>
</script> -->
{% endblock %}

View File

@@ -96,7 +96,7 @@ from khoj.utils.initialization import initialization
def shutdown_scheduler():
logger.info("🌑 Shutting down Khoj")
state.scheduler.shutdown()
# state.scheduler.shutdown()
def run(should_start_server=True):
@@ -134,17 +134,17 @@ def run(should_start_server=True):
poll_task_scheduler()
# Setup Background Scheduler
from django_apscheduler.jobstores import DjangoJobStore
# from django_apscheduler.jobstores import DjangoJobStore
state.scheduler = BackgroundScheduler(
{
"apscheduler.timezone": "UTC",
"apscheduler.job_defaults.misfire_grace_time": "60", # Useful to run scheduled jobs even when worker delayed because it was busy or down
"apscheduler.job_defaults.coalesce": "true", # Combine multiple jobs into one if they are scheduled at the same time
}
)
state.scheduler.add_jobstore(DjangoJobStore(), "default")
state.scheduler.start()
# state.scheduler = BackgroundScheduler(
# {
# "apscheduler.timezone": "UTC",
# "apscheduler.job_defaults.misfire_grace_time": "60", # Useful to run scheduled jobs even when worker delayed because it was busy or down
# "apscheduler.job_defaults.coalesce": "true", # Combine multiple jobs into one if they are scheduled at the same time
# }
# )
# state.scheduler.add_jobstore(DjangoJobStore(), "default")
# state.scheduler.start()
# Start Server
configure_routes(app)