mirror of
https://github.com/unraid/webgui.git
synced 2026-04-26 12:20:42 -05:00
Replace nchan communication for post request
Informational functions which call "openChanges" are now processed using post requests, this solves the issue that sometimes an empty window is displayed.
This commit is contained in:
@@ -24,7 +24,7 @@ if (isset($_POST['kill']) && $_POST['kill'] > 1) {
|
||||
die();
|
||||
}
|
||||
|
||||
$start = isset($_POST['start']) && $_POST['start'] == 1;
|
||||
$start = $_POST['start'] ?? 0;
|
||||
[$command,$args] = explode(' ',unscript($_POST['cmd']??''),2);
|
||||
|
||||
// find absolute path of command
|
||||
@@ -37,8 +37,14 @@ if ($command && strncmp($name,$path,strlen($path))===0) {
|
||||
if (isset($_POST['pid'])) {
|
||||
// return running pid
|
||||
$pid = pgrep($name);
|
||||
} elseif ($start or !pgrep($name)) {
|
||||
// start command in background and return pid
|
||||
} elseif ($start==2) {
|
||||
// execute command and return result - post request
|
||||
$run = popen("$name $args",'r');
|
||||
while (!feof($run)) echo fgets($run);
|
||||
pclose($run);
|
||||
$pid = '';
|
||||
} elseif ($start==1 or !pgrep($name)) {
|
||||
// start command in background and return pid - nchan channel
|
||||
$pid = exec("nohup bash -c 'sleep .3 && $name $args' 1>/dev/null 2>&1 & echo \$!");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user