mirror of
https://github.com/unraid/webgui.git
synced 2026-04-26 12:20:42 -05:00
Improved background process detection and handling
This commit is contained in:
@@ -246,11 +246,32 @@ $('div[id=title]:not(":last, .disable_diskio")').each(function(){$(this).append(
|
||||
<?endif;?>
|
||||
$('.tooltip_diskio').tooltipster({delay:100,trigger:'custom',triggerOpen:{mouseenter:true},triggerClose:{click:false,scroll:true,mouseleave:true}});
|
||||
toggle_diskio(true);
|
||||
<?
|
||||
$parity = $spot ? "<br><small>_(Disabled)_ -- _(Parity operation is running)_</small>" : "";
|
||||
$mover = file_exists('/var/run/mover.pid') ? "<br><small>_(Disabled)_ -- _(Mover is running)_</small>" : "";
|
||||
$btrfs = exec('pgrep -cf /sbin/btrfs') ? "<br><small>_(Disabled)_ -- _(BTRFS operation is running)_</small>" : "";
|
||||
?>
|
||||
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
var mymonitor = new NchanSubscriber('/sub/mymonitor',{subscriber:'websocket'});
|
||||
mymonitor.on('message', function(state) {
|
||||
switch (state) {
|
||||
case '0': // normal operation
|
||||
$('#stop_button').prop('disabled',false);
|
||||
$('#stop_text').html("");
|
||||
break;
|
||||
case '1': // parity running
|
||||
$('#stop_button').prop('disabled',true);
|
||||
$('#stop_text').html("<br><small>_(Disabled)_ -- _(Parity operation is running)_</small>");
|
||||
break;
|
||||
case '2': // mover running
|
||||
$('#stop_button').prop('disabled',true);
|
||||
$('#stop_text').html("<br><small>_(Disabled)_ -- _(Mover is running)_</small>");
|
||||
break;
|
||||
case '3': // btrfs running
|
||||
$('#stop_button').prop('disabled',true);
|
||||
$('#stop_text').html("<br><small>_(Disabled)_ -- _(BTRFS operation is running)_</small>");
|
||||
break;
|
||||
}
|
||||
});
|
||||
mymonitor.start();
|
||||
<?endif;?>
|
||||
|
||||
var arraymonitor = new NchanSubscriber('/sub/arraymonitor',{subscriber:'websocket'});
|
||||
arraymonitor.on('message', function(state) {
|
||||
if (state==1 && !timers.arraymonitor) timers.arraymonitor = setTimeout(refresh,1250);
|
||||
@@ -350,8 +371,8 @@ function formatWarning(val) {
|
||||
<?switch ($var['fsState']):
|
||||
case "Started":?>
|
||||
<tr><td><?status_indicator()?>**_(Started)_<?=(($var['startMode']=='Maintenance')?' - _(Maintenance Mode)_':'')?>**</td>
|
||||
<td><input type="button" value="_(Stop)_" onclick="stopArray(this.form)"<?if ($parity||$mover||$btrfs):?> disabled<?endif;?>></td>
|
||||
<td id="stop">**_(Stop)_** _(will take the array off-line)_.<?=$parity?:$mover?:$btrfs?:''?></td></tr>
|
||||
<td><input type="button" id="stop_button" value="_(Stop)_" onclick="stopArray(this.form)"></td>
|
||||
<td>**_(Stop)_** _(will take the array off-line)_.<span id="stop_text"></span></td></tr>
|
||||
<? if ($var['fsNumUnmountable']>0):?>
|
||||
<tr><td>**<?=_('Unmountable disk'.($var['fsNumUnmountable']==1?'':'s').' present')?>:**<br>
|
||||
<? $cache = [];
|
||||
@@ -632,24 +653,6 @@ function formatWarning(val) {
|
||||
</table>
|
||||
</form>
|
||||
<!-- markdown fix --></p><?if (isset($display['sleep'])) eval('?>'.parse_file($display['sleep']))?>
|
||||
<?if ($btrfs):?>
|
||||
<script>
|
||||
function enable_stop() {
|
||||
$.get('/webGui/include/ReloadPage.php',function(data) {
|
||||
switch (data) {
|
||||
case 'disable':
|
||||
setTimeout(enable_stop,5000);
|
||||
break;
|
||||
case 'enable':
|
||||
var stop = $('td#stop');
|
||||
stop.html(stop.html().replace("<?=$btrfs?>",""));
|
||||
$('input[value="_(Stop)_"]').prop('disabled',false);
|
||||
break;}
|
||||
});
|
||||
}
|
||||
enable_stop();
|
||||
</script>
|
||||
<?endif;?>
|
||||
|
||||
:array_status_help:
|
||||
<?if ($var['fsState']=="Stopped"):?>
|
||||
|
||||
@@ -68,7 +68,7 @@ if ($.cookie('deletepool')!=null) {
|
||||
done();
|
||||
}
|
||||
<?if (strpos($disk['fsType'],"btrfs")!==false):?>
|
||||
function presetBTRFS(form,job) {
|
||||
function presetBTRFS(form,hour) {
|
||||
var mode = form.mode.value;
|
||||
form.min.disabled = mode==0;
|
||||
form.day.disabled = mode==0 || mode!=3;
|
||||
@@ -77,9 +77,9 @@ function presetBTRFS(form,job) {
|
||||
form.hour2.disabled = mode==0;
|
||||
form.day.value = form.day.disabled ? '*' : (form.day.value=='*' ? 0 : form.day.value);
|
||||
form.dotm.value = form.dotm.disabled ? '*' : (form.dotm.value=='*' ? 1 : form.dotm.value);
|
||||
if (mode==1) {$(job+'-hour1').hide(); $(job+'-hour2').show();} else {$(job+'-hour2').hide(); $(job+'-hour1').show();}
|
||||
if (mode==1) {$(hour+'1').hide(); $(hour+'2').show();} else {$(hour+'2').hide(); $(hour+'1').show();}
|
||||
}
|
||||
function prepareBTRFS(form,cookie,value) {
|
||||
function prepareBTRFS(form) {
|
||||
var include = '';
|
||||
var mode = form.mode.value;
|
||||
form.hour.value = mode!=1 ? form.hour1.value : form.hour2.value;
|
||||
@@ -96,7 +96,6 @@ function prepareBTRFS(form,cookie,value) {
|
||||
item = form.disk.options[0];
|
||||
item.value = include;
|
||||
item.selected = true;
|
||||
$.cookie(cookie,value)
|
||||
}
|
||||
<?endif;?>
|
||||
function prepareDeviceInfo(form) {
|
||||
@@ -346,7 +345,7 @@ $(function() {
|
||||
if ($.cookie('rfs-check-<?=$tag?>')) btrfs = rfsCheck($.cookie('rfs-check-<?=$tag?>'));
|
||||
if ($.cookie('xfs-check-<?=$tag?>')) btrfs = xfsCheck($.cookie('xfs-check-<?=$tag?>'));
|
||||
if (!btrfs) {
|
||||
$.get('/webGui/include/ReloadPage.php',{mount:'<?=$tag?>'},function(a){
|
||||
$.post('/webGui/include/FileSystemStatus.php',{cmd:'status',path:'<?=$tag?>'},function(a){
|
||||
var action = a.split(',');
|
||||
for (var i=0,busy; busy=action[i]; i++) {
|
||||
switch (busy) {
|
||||
@@ -561,14 +560,14 @@ _(btrfs balance status)_:
|
||||
</form>
|
||||
<hr>
|
||||
<?$balance = "balance_$tag";?>
|
||||
<form markdown="1" name="balance_schedule" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareBTRFS(this,'btrfs-balance-<?=$tag?>','/mnt/<?=$tag?>')">
|
||||
<form markdown="1" name="balance_schedule" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareBTRFS(this)">
|
||||
<input type="hidden" name="#file" value="dynamix/dynamix.cfg">
|
||||
<input type="hidden" name="#section" value="balance_<?=$tag?>">
|
||||
<input type="hidden" name="#include" value="/webGui/include/update.btrfs.php">
|
||||
<input type="hidden" name="#job" value="balance_<?=$tag?>;<?=$docroot?>/plugins/dynamix/scripts/btrfs_balance start /mnt/<?=$tag?>">
|
||||
<input type="hidden" name="hour" value="">
|
||||
_(Balance schedule)_:
|
||||
: <select name="mode" onchange="presetBTRFS(this.form,'#balance')">
|
||||
: <select name="mode" onchange="presetBTRFS(this.form,'#balance-hour')">
|
||||
<?for ($m=0; $m<count($mode); $m++):?>
|
||||
<?=mk_option($$balance['mode'], strval($m), _($mode[$m]))?>
|
||||
<?endfor;?>
|
||||
@@ -654,14 +653,14 @@ _(btrfs scrub status)_:
|
||||
</form>
|
||||
<hr>
|
||||
<?$scrub = "scrub_$tag";?>
|
||||
<form markdown="1" name="scrub_schedule" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareBTRFS(this,'btrfs-scrub-<?=$tag?>','/mnt/<?=$tag?>')">
|
||||
<form markdown="1" name="scrub_schedule" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareBTRFS(this)">
|
||||
<input type="hidden" name="#file" value="dynamix/dynamix.cfg">
|
||||
<input type="hidden" name="#section" value="scrub_<?=$tag?>">
|
||||
<input type="hidden" name="#include" value="/webGui/include/update.btrfs.php">
|
||||
<input type="hidden" name="#job" value="scrub_<?=$tag?>;<?=$docroot?>/plugins/dynamix/scripts/btrfs_scrub start /mnt/<?=$tag?> -r">
|
||||
<input type="hidden" name="hour" value="">
|
||||
_(Scrub schedule)_:
|
||||
: <select name="mode" onchange="presetBTRFS(this.form,'#scrub')">
|
||||
: <select name="mode" onchange="presetBTRFS(this.form,'#scrub-hour')">
|
||||
<?for ($m=0; $m<count($mode); $m++):?>
|
||||
<?=mk_option($$scrub['mode'], strval($m), _($mode[$m]))?>
|
||||
<?endfor;?>
|
||||
@@ -936,8 +935,8 @@ _(Name)_:
|
||||
<?if (strpos($disk['fsType'],"btrfs")!==false):?>
|
||||
<script>
|
||||
$(function(){
|
||||
presetBTRFS(document.balance_schedule,'#balance');
|
||||
presetBTRFS(document.scrub_schedule,'#scrub');
|
||||
presetBTRFS(document.balance_schedule,'#balance-hour');
|
||||
presetBTRFS(document.scrub_schedule,'#scrub-hour');
|
||||
});
|
||||
</script>
|
||||
<?endif;?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, Bergware International.
|
||||
/* Copyright 2005-2022, Lime Technology
|
||||
* Copyright 2012-2022, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -12,18 +12,21 @@
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
|
||||
$cmd = $_POST['cmd'];
|
||||
$path = $_POST['path'];
|
||||
|
||||
switch ($cmd) {
|
||||
case 'status':
|
||||
exec("ps -C btrfs -o cmd=|awk '/$path\$/{print $2}'",$action);
|
||||
echo implode(',',$action);
|
||||
break;
|
||||
case 'balance':
|
||||
case 'scrub':
|
||||
echo shell_exec("/sbin/btrfs $cmd status $path");
|
||||
break;
|
||||
default:
|
||||
[$dev,$id] = my_explode(' ',$path);
|
||||
[$dev,$id] = explode(' ',$path);
|
||||
$file = "/var/lib/$cmd/check.status.$id";
|
||||
if (file_exists($file)) {
|
||||
switch ($cmd) {
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2022, Lime Technology
|
||||
* Copyright 2015-2022, Bergware International
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Secure.php";
|
||||
|
||||
$mount = unscript($_GET['mount']??'');
|
||||
if ($mount) {
|
||||
exec("ps -C btrfs -o cmd=|awk '/\/mnt\/$mount\$/{print $2}'",$action);
|
||||
echo implode(',',$action);
|
||||
} else {
|
||||
echo exec('pgrep -cf /sbin/btrfs')>0 ? 'disable' : 'enable';
|
||||
}
|
||||
?>
|
||||
@@ -105,20 +105,21 @@ while (true) {
|
||||
}
|
||||
delete_file($stamps,$resync);
|
||||
}
|
||||
switch ($var['fsState']) {
|
||||
case 'Copying':
|
||||
$fsState = $var['fsCopyPrcnt']."% "._('completed');
|
||||
break;
|
||||
case 'Clearing':
|
||||
$fsState = $var['fsClearPrcnt']."% "._('completed');
|
||||
break;
|
||||
default:
|
||||
$fsState = substr($var['fsState'],-3)!='ing' ? 'stop' : '';
|
||||
break;
|
||||
}
|
||||
if ($var['fsState']=='Copying') $fsState = $var['fsCopyPrcnt']."% "._('completed');
|
||||
elseif ($var['fsState']=='Clearing') $fsState = $var['fsClearPrcnt']."% "._('completed');
|
||||
elseif (substr($var['fsState'],-3)!='ing') $fsState = 'stop';
|
||||
else $fsState = '';
|
||||
|
||||
if ($var['fsState']!='Started') $process = -1;
|
||||
elseif ($spot) $process = 1;
|
||||
elseif (file_exists('/var/run/mover.pid')) $process = 2;
|
||||
elseif (exec('pgrep -cf /sbin/btrfs')>0) $process = 3;
|
||||
else $process = 0;
|
||||
|
||||
publish('parity', implode(';',$data));
|
||||
publish('paritymonitor', $spot>0 ? 1 : 0);
|
||||
publish('fsState', $fsState);
|
||||
publish('mymonitor', $process);
|
||||
sleep(1);
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user