+ /**
+ * Checks if the system is ready.
+ *
+ * Several system parameters like memory, connections and processes are checked.
+ *
+ * @return boolean
+ */
+ public static function isReady()
+ {
+ // Count active workers and compare them with a maximum value that depends on the load
+ if (self::tooMuchWorkers()) {
+ Logger::info('Active worker limit reached, quitting.');
+ return false;
+ }
+
+ // Do we have too few memory?
+ if (DI::process()->isMinMemoryReached()) {
+ Logger::info('Memory limit reached, quitting.');
+ return false;
+ }
+
+ // Possibly there are too much database connections
+ if (self::maxConnectionsReached()) {
+ Logger::info('Maximum connections reached, quitting.');
+ return false;
+ }
+
+ // Possibly there are too much database processes that block the system
+ if (DI::process()->isMaxProcessesReached()) {
+ Logger::info('Maximum processes reached, quitting.');
+ return false;
+ }
+
+ return true;
+ }
+