public function create()
{
if ($this->check()) {
//We are using warning here to eliminate messages flood in the service, nevertheless it's actually error.
$this->log($this->pidExistLevel, "Cannot start service, another one is already running! pid:%d, file:%s", $this->pid, $this->file);
exit;
}
//Creates pid file
$this->pid = posix_getpid();
$res = file_put_contents($this->file, $this->pid);
if ($res === false) {
$this->log("ERROR", "Cannot create pid file: %s", $this->file);
exit;
}
@chmod($this->file, 0666);
}