mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-31 21:12:41 +00:00
Handle last possible PID failures
Opening the PID file can still fail separately, though this is unlikely
This commit is contained in:
parent
9595c4f019
commit
e8cab78bd6
3 changed files with 15 additions and 6 deletions
|
@ -104,8 +104,10 @@ abstract class AbstractException extends \Exception {
|
||||||
"Rule/Exception.invalidPattern" => 10701,
|
"Rule/Exception.invalidPattern" => 10701,
|
||||||
"CLI/Exception.pidNotFile" => 10801,
|
"CLI/Exception.pidNotFile" => 10801,
|
||||||
"CLI/Exception.pidDirNotFound" => 10802,
|
"CLI/Exception.pidDirNotFound" => 10802,
|
||||||
"CLI/Exception.pidUnwritable" => 10803,
|
"CLI/Exception.pidUnusable" => 10803,
|
||||||
"CLI/Exception.pidUncreatable" => 10804,
|
"CLI/Exception.pidUnreadable" => 10804,
|
||||||
|
"CLI/Exception.pidUnwritable" => 10805,
|
||||||
|
"CLI/Exception.pidUncreatable" => 10806,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $symbol;
|
protected $symbol;
|
||||||
|
|
10
lib/CLI.php
10
lib/CLI.php
|
@ -339,13 +339,17 @@ USAGE_TEXT;
|
||||||
} elseif ($base = @realpath($dir)) {
|
} elseif ($base = @realpath($dir)) {
|
||||||
$out = "$base/$file";
|
$out = "$base/$file";
|
||||||
if (file_exists($out)) {
|
if (file_exists($out)) {
|
||||||
if (!is_writable($out)) {
|
if (!is_readable($out) && !is_writable($out)) {
|
||||||
throw new \Exception("PID file is not writable");
|
throw new CLI\Exception("pidUnusable", ['pidfile' => $out]);
|
||||||
|
} elseif (!is_readable($out)) {
|
||||||
|
throw new CLI\Exception("pidunreadable", ['pidfile' => $out]);
|
||||||
|
} elseif (!is_writable($out)) {
|
||||||
|
throw new CLI\Exception("pidUnwritable", ['pidfile' => $out]);
|
||||||
} elseif (!is_file($out)) {
|
} elseif (!is_file($out)) {
|
||||||
throw new CLI\Exception("pidNotFile", ['pidfile' => $out]);
|
throw new CLI\Exception("pidNotFile", ['pidfile' => $out]);
|
||||||
}
|
}
|
||||||
} elseif (!is_writable($base)) {
|
} elseif (!is_writable($base)) {
|
||||||
throw new \Exception("Cannot create PID file");
|
throw new CLI\Exception("pidUncreatable", ['pidfile' => $out]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception("pidDirNotFound", ['piddir' => $dir]);
|
throw new \Exception("pidDirNotFound", ['piddir' => $dir]);
|
||||||
|
|
|
@ -210,6 +210,9 @@ return [
|
||||||
'Exception.JKingWeb/Arsse/Rule/Exception.invalidPattern' => 'Specified rule pattern is invalid',
|
'Exception.JKingWeb/Arsse/Rule/Exception.invalidPattern' => 'Specified rule pattern is invalid',
|
||||||
'Exception.JKingWeb/Arsse/CLI/Exception.pidNotFile' => 'Specified PID file location "{pidfile}" must be a regular file',
|
'Exception.JKingWeb/Arsse/CLI/Exception.pidNotFile' => 'Specified PID file location "{pidfile}" must be a regular file',
|
||||||
'Exception.JKingWeb/Arsse/CLI/Exception.pidDirNotFound' => 'Parent directory "{piddir}" of PID file does not exist',
|
'Exception.JKingWeb/Arsse/CLI/Exception.pidDirNotFound' => 'Parent directory "{piddir}" of PID file does not exist',
|
||||||
|
'Exception.JKingWeb/Arsse/CLI/Exception.pidUnreadable' => 'Insufficient permissions to open PID file "{pidfile}" for reading',
|
||||||
'Exception.JKingWeb/Arsse/CLI/Exception.pidUnwritable' => 'Insufficient permissions to open PID file "{pidfile}" for writing',
|
'Exception.JKingWeb/Arsse/CLI/Exception.pidUnwritable' => 'Insufficient permissions to open PID file "{pidfile}" for writing',
|
||||||
'Exception.JKingWeb/Arsse/CLI/Exception.pidNotFile' => 'Specified PID file location "{pidfile}" must be a regular file',
|
'Exception.JKingWeb/Arsse/CLI/Exception.pidUnusable' => 'Insufficient permissions to open PID file "{pidfile}" for reading or writing',
|
||||||
|
'Exception.JKingWeb/Arsse/CLI/Exception.pidUncreatable' => 'Insufficient permissions to create PID file "{pidfile}"',
|
||||||
|
'Exception.JKingWeb/Arsse/CLI/Exception.pidNotFile' => 'PID file "{pidfile}" must be a regular file',
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue