+ $this->processModel = $processModel;
+ $this->pid = getmypid();
+ }
+
+ /**
+ * Log active processes into the "process" table
+ */
+ public function start()
+ {
+ $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
+
+ $command = basename($trace[0]['file']);
+
+ $this->processModel->deleteInactive();
+ $this->processModel->insert($command, $this->pid);
+ }
+
+ /**
+ * Remove the active process from the "process" table
+ *
+ * @return bool
+ * @throws \Exception
+ */
+ public function end()
+ {
+ return $this->processModel->deleteByPid($this->pid);