mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Merge pull request #11135 from uberbrady/improve_restore_erroring
Do some better erroring if you can't launch the mysql binary
This commit is contained in:
commit
11db243514
|
@ -227,6 +227,9 @@ class RestoreFromBackup extends Command
|
||||||
return $this->error('Unable to invoke mysql via CLI');
|
return $this->error('Unable to invoke mysql via CLI');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stream_set_blocking($pipes[1], false); // use non-blocking reads for stdout
|
||||||
|
stream_set_blocking($pipes[2], false); // use non-blocking reads for stderr
|
||||||
|
|
||||||
// $this->info("Stdout says? ".fgets($pipes[1])); //FIXME: I think we might need to set non-blocking mode to use this properly?
|
// $this->info("Stdout says? ".fgets($pipes[1])); //FIXME: I think we might need to set non-blocking mode to use this properly?
|
||||||
// $this->info("Stderr says? ".fgets($pipes[2])); //FIXME: ditto, same.
|
// $this->info("Stderr says? ".fgets($pipes[2])); //FIXME: ditto, same.
|
||||||
// should we read stdout?
|
// should we read stdout?
|
||||||
|
@ -247,19 +250,26 @@ class RestoreFromBackup extends Command
|
||||||
}
|
}
|
||||||
$bytes_read = 0;
|
$bytes_read = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
while (($buffer = fgets($sql_contents, self::$buffer_size)) !== false) {
|
while (($buffer = fgets($sql_contents, self::$buffer_size)) !== false) {
|
||||||
$bytes_read += strlen($buffer);
|
$bytes_read += strlen($buffer);
|
||||||
// \Log::debug("Buffer is: '$buffer'");
|
// \Log::debug("Buffer is: '$buffer'");
|
||||||
$bytes_written = fwrite($pipes[0], $buffer);
|
$bytes_written = fwrite($pipes[0], $buffer);
|
||||||
|
|
||||||
if ($bytes_written === false) {
|
if ($bytes_written === false) {
|
||||||
$stdout = fgets($pipes[1]);
|
throw new Exception("Unable to write to pipe");
|
||||||
$this->info($stdout);
|
|
||||||
$stderr = fgets($pipes[2]);
|
|
||||||
$this->info($stderr);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::error("Error during restore!!!! ".$e->getMessage());
|
||||||
|
$err_out = fgets($pipes[1]);
|
||||||
|
$err_err = fgets($pipes[2]);
|
||||||
|
\Log::error("Error OUTPUT: ".$err_out);
|
||||||
|
$this->info($err_out);
|
||||||
|
\Log::error("Error ERROR : ".$err_err);
|
||||||
|
$this->error($err_err);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
if (!feof($sql_contents) || $bytes_read == 0) {
|
if (!feof($sql_contents) || $bytes_read == 0) {
|
||||||
return $this->error("Not at end of file for sql file, or zero bytes read. aborting!");
|
return $this->error("Not at end of file for sql file, or zero bytes read. aborting!");
|
||||||
|
|
Loading…
Reference in a new issue