mirror of
https://github.com/unraid/webgui.git
synced 2026-02-21 17:29:15 -06:00
Merge pull request #1775 from dlandon/master
Mover status button on 'Array Operation' page; Docker PID Limit setting.
This commit is contained in:
@@ -1008,6 +1008,10 @@ Instead of chevrons indicating more data for Port and Volume mapping, all data i
|
||||
The time in seconds to allow a container to gracefully stop before forcing it to stop
|
||||
:end
|
||||
|
||||
:docker_pid_limit_help:
|
||||
Set a PID Limit to limit the number of PIDs that a docker can use. The default is 2048. Set to zero for unlimited PIDs (not recommended).
|
||||
:end
|
||||
|
||||
:docker_vdisk_type_help:
|
||||
Select where to keep the Docker persistent state.
|
||||
|
||||
|
||||
@@ -145,6 +145,11 @@ _(Docker Stop Timeout)_ (_(seconds)_):
|
||||
|
||||
:docker_timeout_help:
|
||||
|
||||
_(Docker PID Limit)_:
|
||||
: <input class='narrow' id="DOCKER_PID_LIMIT" type="number" name="DOCKER_PID_LIMIT" min='1' value="<?=_var($dockercfg,'DOCKER_PID_LIMIT')?>" placeholder="2048">
|
||||
|
||||
:docker_pid_limit_help:
|
||||
|
||||
<?if ($DockerStopped):?>
|
||||
|
||||
_(Docker data-root)_:
|
||||
|
||||
@@ -8,3 +8,4 @@ DOCKER_USER_NETWORKS="remove"
|
||||
DOCKER_ALLOW_ACCESS=""
|
||||
DOCKER_TIMEOUT=10
|
||||
DOCKER_READMORE="yes"
|
||||
DOCKER_PID_LIMIT=""
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
/* Read the docker configuration file. */
|
||||
$cfgfile = "/boot/config/docker.cfg";
|
||||
$config_ini = @parse_ini_file($cfgfile, true, INI_SCANNER_RAW);
|
||||
$cfg = ($config_ini !== false) ? $config_ini : [];
|
||||
|
||||
function addRoute($ct) {
|
||||
// add static route(s) for remote WireGuard access
|
||||
[$pid,$net] = array_pad(explode(' ',exec("docker inspect --format='{{.State.Pid}} {{.NetworkSettings.Networks}}' $ct")),2,'');
|
||||
@@ -301,15 +306,22 @@ function xmlToCommand($xml, $create_paths=false) {
|
||||
$Devices[] = escapeshellarg($hostConfig);
|
||||
}
|
||||
}
|
||||
$logSize = $logFile = '';
|
||||
if (($cfg['DOCKER_LOG_ROTATION']??'')=='yes') {
|
||||
$logSize = $cfg['DOCKER_LOG_SIZE'] ?? '10m';
|
||||
$logSize = "--log-opt max-size='$logSize'";
|
||||
$logFile = $cfg['DOCKER_LOG_FILES'] ?? '1';
|
||||
$logFile = "--log-opt max-file='$logFile'";
|
||||
|
||||
// Add pid limit if user has not specified it as an extra parameter
|
||||
$pidsLimit = preg_match('/--pids-limit (\d+)/', $xml['ExtraParams'], $matches) ? $matches[1] : null;
|
||||
if ($pidsLimit === null) {
|
||||
$pid_limit = "--pids-limit ";
|
||||
if (($cfg['DOCKER_PID_LIMIT']??'') != "") {
|
||||
$pid_limit .= $cfg['DOCKER_PID_LIMIT'];
|
||||
} else {
|
||||
$pid_limit .= "2048";
|
||||
}
|
||||
} else {
|
||||
$pid_limit = "";
|
||||
}
|
||||
$cmd = sprintf($docroot.'/plugins/dynamix.docker.manager/scripts/docker create %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s',
|
||||
$cmdName, $cmdNetwork, $cmdMyIP, $cmdCPUset, $logSize, $logFile, $cmdPrivileged, implode(' -e ', $Variables), implode(' -l ', $Labels), implode(' -p ', $Ports), implode(' -v ', $Volumes), implode(' --device=', $Devices), $xml['ExtraParams'], escapeshellarg($xml['Repository']), $xml['PostArgs']);
|
||||
|
||||
$cmd = sprintf($docroot.'/plugins/dynamix.docker.manager/scripts/docker create %s %s %s %s %s %s %s %s %s %s %s %s %s %s',
|
||||
$cmdName, $cmdNetwork, $cmdMyIP, $cmdCPUset, $pid_limit, $cmdPrivileged, implode(' -e ', $Variables), implode(' -l ', $Labels), implode(' -p ', $Ports), implode(' -v ', $Volumes), implode(' --device=', $Devices), $xml['ExtraParams'], escapeshellarg($xml['Repository']), $xml['PostArgs']);
|
||||
return [preg_replace('/\s\s+/', ' ', $cmd), $xml['Name'], $xml['Repository']];
|
||||
}
|
||||
function stopContainer($name, $t=false, $echo=true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2015-2024, Lime Technology
|
||||
/* Copyright 2015-2023, Lime Technology
|
||||
* Copyright 2015-2016, Guilherme Jardim, Eric Schultz, Jon Panozzo.
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
@@ -13,28 +13,46 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
/* Define the path to the docker configuration file */
|
||||
$cfgfile = "/boot/config/docker.cfg";
|
||||
|
||||
/* Define the default configuration values */
|
||||
$cfg_defaults = [
|
||||
"DOCKER_ENABLED" => "no",
|
||||
"DOCKER_NETWORK_TYPE" => "1",
|
||||
"DOCKER_IMAGE_FILE" => "/mnt/user/system/docker/docker.img",
|
||||
"DOCKER_IMAGE_SIZE" => "20",
|
||||
"DOCKER_APP_CONFIG_PATH" => "/mnt/user/appdata/",
|
||||
"DOCKER_APP_UNRAID_PATH" => "",
|
||||
"DOCKER_READMORE" => "yes"
|
||||
"DOCKER_ENABLED" => "no",
|
||||
"DOCKER_IMAGE_FILE" => "/mnt/user/system/docker/docker.img",
|
||||
"DOCKER_IMAGE_SIZE" => "20",
|
||||
"DOCKER_APP_CONFIG_PATH" => "/mnt/user/appdata/",
|
||||
"DOCKER_APP_UNRAID_PATH" => "",
|
||||
"DOCKER_READMORE" => "yes",
|
||||
"DOCKER_PID_LIMIT" => ""
|
||||
];
|
||||
|
||||
/* Initialize the new configuration with the default values */
|
||||
$cfg_new = $cfg_defaults;
|
||||
|
||||
/* Check if the configuration file exists */
|
||||
if (file_exists($cfgfile)) {
|
||||
$cfg_old = parse_ini_file($cfgfile);
|
||||
if (!empty($cfg_old)) {
|
||||
$cfg_new = array_merge($cfg_defaults, $cfg_old);
|
||||
if (empty(array_diff($cfg_new, $cfg_old))) unset($cfg_new);
|
||||
}
|
||||
/* Parse the existing configuration file */
|
||||
$cfg_old = parse_ini_file($cfgfile);
|
||||
|
||||
/* If the existing configuration is not empty, merge it with the defaults */
|
||||
if (!empty($cfg_old)) {
|
||||
/* Merge only missing keys from defaults */
|
||||
$cfg_new = array_merge($cfg_defaults, $cfg_old);
|
||||
|
||||
/* If there are no changes between the new and old configurations, unset the new configuration */
|
||||
if (empty(array_diff_assoc($cfg_new, $cfg_old))) {
|
||||
$cfg_new = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If the new configuration is set, write it to the configuration file */
|
||||
if (isset($cfg_new)) {
|
||||
$tmp = '';
|
||||
foreach ($cfg_new as $key => $value) $tmp .= "$key=\"$value\"\n";
|
||||
file_put_contents($cfgfile, $tmp);
|
||||
$tmp = '';
|
||||
foreach ($cfg_new as $key => $value) {
|
||||
$tmp .= "$key=\"$value\"\n";
|
||||
}
|
||||
file_put_contents($cfgfile, $tmp);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -126,7 +126,7 @@ while (true) {
|
||||
$process = -1;
|
||||
} elseif ($spot > 0 && $bytes > 0) {
|
||||
$process = 1;
|
||||
} elseif (file_exists('/var/run/mover.pid')) {
|
||||
} elseif (_var($var, 'shareMoverActive') == "yes") {
|
||||
$process = 2;
|
||||
} elseif (exec('ps -C btrfs -o cmd=|grep -cv show') > 0) {
|
||||
$process = 3;
|
||||
|
||||
Reference in New Issue
Block a user