|
|
@@ -223,6 +223,20 @@ int main(int argc, char* argv[]) {
|
|
|
std::signal(SIGINT, signalHandler);
|
|
|
std::signal(SIGTERM, signalHandler);
|
|
|
|
|
|
+#ifdef HAVE_SYSTEMD
|
|
|
+ // v1.7.5: extend the systemd start timeout while recovery is
|
|
|
+ // running. Default TimeoutStartSec=90s + a 5-min unit cap is
|
|
|
+ // enough for most datasets, but very large databases (millions
|
|
|
+ // of docs, multi-GB WAL) can exceed that. EXTEND_TIMEOUT_USEC
|
|
|
+ // pushes systemd's clock back a fixed interval — we re-issue
|
|
|
+ // it on each major step so the watchdog never fires mid-replay.
|
|
|
+ // 600 seconds (10 min) per step is generous and only affects
|
|
|
+ // the start phase; once READY is sent, normal WatchdogSec
|
|
|
+ // semantics take over.
|
|
|
+ sd_notify(0, "EXTEND_TIMEOUT_USEC=600000000");
|
|
|
+ sd_notify(0, "STATUS=Initializing — running recovery and migrations");
|
|
|
+#endif
|
|
|
+
|
|
|
// Initialize service. Recovery-refused is reported via the
|
|
|
// recovery_outcome_ state (banner printed by DatabaseService) and
|
|
|
// maps to exit code 10.
|
|
|
@@ -240,12 +254,25 @@ int main(int argc, char* argv[]) {
|
|
|
service.setReadOnly(true, "started with --read-only flag");
|
|
|
}
|
|
|
|
|
|
+#ifdef HAVE_SYSTEMD
|
|
|
+ sd_notify(0, "EXTEND_TIMEOUT_USEC=600000000");
|
|
|
+ sd_notify(0, "STATUS=Starting gRPC server");
|
|
|
+#endif
|
|
|
+
|
|
|
// Start service
|
|
|
service.start();
|
|
|
|
|
|
#ifdef HAVE_SYSTEMD
|
|
|
- // Notify systemd we're ready
|
|
|
+ // v1.7.5: only notify READY *after* full initialization +
|
|
|
+ // service.start() — recovery is done, migrations are applied,
|
|
|
+ // gRPC is listening. With the unit set to Type=notify,
|
|
|
+ // dependents (shadowman-tools, -gateway, -server) block in
|
|
|
+ // their own systemd start until this READY arrives, so they
|
|
|
+ // can never observe an in-recovery DB and silently fall back
|
|
|
+ // to defaults. Pre-1.7.5 the unit was Type=simple — sd_notify
|
|
|
+ // was effectively decoration.
|
|
|
sd_notify(0, "READY=1");
|
|
|
+ sd_notify(0, "STATUS=Ready");
|
|
|
spdlog::info("Notified systemd: READY");
|
|
|
#endif
|
|
|
|