Browse Source

Handle last possible PID failures

Opening the PID file can still fail separately, though this is unlikely
rpm
J. King 3 years ago
parent
commit
e8cab78bd6
  1. 6
      lib/AbstractException.php
  2. 10
      lib/CLI.php
  3. 5
      locale/en.php

6
lib/AbstractException.php

@ -104,8 +104,10 @@ abstract class AbstractException extends \Exception {
"Rule/Exception.invalidPattern" => 10701,
"CLI/Exception.pidNotFile" => 10801,
"CLI/Exception.pidDirNotFound" => 10802,
"CLI/Exception.pidUnwritable" => 10803,
"CLI/Exception.pidUncreatable" => 10804,
"CLI/Exception.pidUnusable" => 10803,
"CLI/Exception.pidUnreadable" => 10804,
"CLI/Exception.pidUnwritable" => 10805,
"CLI/Exception.pidUncreatable" => 10806,
];
protected $symbol;

10
lib/CLI.php

@ -339,13 +339,17 @@ USAGE_TEXT;
} elseif ($base = @realpath($dir)) {
$out = "$base/$file";
if (file_exists($out)) {
if (!is_writable($out)) {
throw new \Exception("PID file is not writable");
if (!is_readable($out) && !is_writable($out)) {
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)) {
throw new CLI\Exception("pidNotFile", ['pidfile' => $out]);
}
} elseif (!is_writable($base)) {
throw new \Exception("Cannot create PID file");
throw new CLI\Exception("pidUncreatable", ['pidfile' => $out]);
}
} else {
throw new \Exception("pidDirNotFound", ['piddir' => $dir]);

5
locale/en.php

@ -210,6 +210,9 @@ return [
'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.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.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…
Cancel
Save