Skip to content

Commit 0c8c825

Browse files
committed
Enable resource limitation module when it is set to 'yes' in hestia.config
1 parent ea3d4b1 commit 0c8c825

File tree

5 files changed

+75
-58
lines changed

5 files changed

+75
-58
lines changed

bin/v-add-user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ if [ "$DISK_QUOTA" = 'yes' ]; then
266266
$BIN/v-update-user-quota "$user"
267267
fi
268268

269-
# Update cgroup
269+
# Update resource limitation (cgroup)
270270
if [ "$RESOURCES_LIMIT" = 'yes' ]; then
271271
$BIN/v-update-user-cgroup "$user"
272272
fi

bin/v-list-sys-config

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ json_list() {
4646
"DEMO_MODE": "'$DEMO_MODE'",
4747
"DISABLE_IP_CHECK": "'$DISABLE_IP_CHECK'",
4848
"DISK_QUOTA": "'$DISK_QUOTA'",
49+
"RESOURCES_LIMIT": "'$RESOURCES_LIMIT'",
4950
"DNS_CLUSTER": "'$DNS_CLUSTER'",
5051
"DNS_CLUSTER_SYSTEM": "'$DNS_CLUSTER_SYSTEM'",
5152
"DNS_SYSTEM": "'$DNS_SYSTEM'",
@@ -189,6 +190,9 @@ shell_list() {
189190
if [ -n "$DISK_QUOTA" ]; then
190191
echo "Disk Quota enabled: $DISK_QUOTA"
191192
fi
193+
if [ -n "$RESOURCES_LIMIT" ]; then
194+
echo "Resource limit with cgroup enabled: $RESOURCES_LIMIT"
195+
fi
192196
if [ -n "$LANGUAGE" ] && [ "$LANGUAGE" != 'en' ]; then
193197
echo "System Language: $LANGUAGE"
194198
fi
@@ -239,7 +243,7 @@ plain_list() {
239243
echo -ne "$PROXY_SSL_PORT\t$FTP_SYSTEM\t$MAIL_SYSTEM\t$IMAP_SYSTEM\t"
240244
echo -ne "$ANTIVIRUS_SYSTEM\t$ANTISPAM_SYSTEM\t$DB_SYSTEM\t"
241245
echo -ne "$DNS_SYSTEM\t$DNS_CLUSTER\t$STATS_SYSTEM\t$BACKUP_SYSTEM\t"
242-
echo -ne "$CRON_SYSTEM\t$DISK_QUOTA\t$FIREWALL_SYSTEM\t$FIREWALL_EXTENSION\t"
246+
echo -ne "$CRON_SYSTEM\t$DISK_QUOTA\t$RESOURCES_LIMIT\t$FIREWALL_SYSTEM\t$FIREWALL_EXTENSION\t"
243247
echo -ne "$FILE_MANAGER\t$REPOSITORY\t$VERSION\t$DEMO_MODE\t$RELEASE_BRANCH\t"
244248
echo -ne "$SMTP_RELAY_HOST\t$SMTP_RELAY_PORT\t$SMTP_RELAY_USER\t"
245249
echo -ne "$UPGRADE_SEND_EMAIL\t$UPGRADE_SEND_EMAIL_LOG\t$THEME\t$LANGUAGE\t$BACKUP_GZIP\t"
@@ -254,7 +258,7 @@ csv_list() {
254258
echo -n "'PROXY_SSL_PORT','FTP_SYSTEM','MAIL_SYSTEM','IMAP_SYSTEM',"
255259
echo -n "'ANTIVIRUS_SYSTEM','ANTISPAM_SYSTEM','DB_SYSTEM',"
256260
echo -n "'DNS_SYSTEM','DNS_CLUSTER','STATS_SYSTEM','BACKUP_SYSTEM',"
257-
echo -n "'CRON_SYSTEM','DISK_QUOTA','FIREWALL_SYSTEM',"
261+
echo -n "'CRON_SYSTEM','DISK_QUOTA','RESOURCES_LIMIT','FIREWALL_SYSTEM',"
258262
echo -n "'FIREWALL_EXTENSION','FILE_MANAGER','REPOSITORY',"
259263
echo -n "'VERSION','DEMO_MODE','RELEASE_BRANCH',"
260264
echo -n "'SMTP_RELAY','SMTP_RELAY_HOST','SMTP_RELAY_PORT','SMTP_RELAY_USER',"
@@ -268,7 +272,7 @@ csv_list() {
268272
echo -n "'$PROXY_SSL_PORT','$FTP_SYSTEM','$MAIL_SYSTEM','$IMAP_SYSTEM',"
269273
echo -n "'$ANTIVIRUS_SYSTEM','$ANTISPAM_SYSTEM','$DB_SYSTEM','$DNS_SYSTEM',"
270274
echo -n "'$DNS_CLUSTER','$STATS_SYSTEM','$BACKUP_SYSTEM','$CRON_SYSTEM',"
271-
echo -n "'$DISK_QUOTA','$FIREWALL_SYSTEM','$FIREWALL_EXTENSION','$FILE_MANAGER',"
275+
echo -n "'$DISK_QUOTA','$RESOURCES_LIMIT','$FIREWALL_SYSTEM','$FIREWALL_EXTENSION','$FILE_MANAGER',"
272276
echo -n "'$REPOSITORY', '$VERSION','$DEMO_MODE','$RELEASE_BRANCH',"
273277
echo -n "'$SMTP_RELAY','$SMTP_RELAY_HOST','$SMTP_RELAY_PORT','$SMTP_RELAY_USER',"
274278
echo -n "'$UPGRADE_SEND_EMAIL','$UPGRADE_SEND_EMAIL_LOG','$THEME','$LANGUAGE',"

bin/v-list-users

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ json_list() {
4949
"DATABASES": "'$DATABASES'",
5050
"CRON_JOBS": "'$CRON_JOBS'",
5151
"DISK_QUOTA": "'$DISK_QUOTA'",
52+
"CPU_QUOTA": "'$CPU_QUOTA'",
53+
"CPU_QUOTA_PERIOD": "'$CPU_QUOTA_PERIOD'",
54+
"MEMORY_LIMIT": "'$MEMORY_LIMIT'",
55+
"SWAP_LIMIT": "'$SWAP_LIMIT'",
5256
"BANDWIDTH": "'$BANDWIDTH'",
5357
"NS": "'$NS'",
5458
"SHELL": "'$SHELL'",
@@ -118,7 +122,8 @@ plain_list() {
118122
echo -ne "$BACKEND_TEMPLATE\t$PROXY_TEMPLATE\t$DNS_TEMPLATE\t"
119123
echo -ne "$WEB_DOMAINS\t$WEB_ALIASES\t$DNS_DOMAINS\t$DNS_RECORDS\t"
120124
echo -ne "$MAIL_DOMAINS\t$MAIL_ACCOUNTS\t$DATABASES\t$CRON_JOBS\t"
121-
echo -ne "$DISK_QUOTA\t$BANDWIDTH\t$NS\t$SHELL\t$BACKUPS\t"
125+
echo -ne "$DISK_QUOTA\t$CPU_QUOTA\t$CPU_QUOTA_PERIOD\t$MEMORY_LIMIT\t"
126+
echo -ne "$SWAP_LIMIT\t$BANDWIDTH\t$NS\t$SHELL\t$BACKUPS\t"
122127
echo -ne "$CONTACT\t$CRON_REPORTS\t$RKEY\t$ROLE\t$SUSPENDED\t"
123128
echo -ne "$SUSPENDED_USERS\t$SUSPENDED_WEB\t$SUSPENDED_DNS\t"
124129
echo -ne "$SUSPENDED_MAIL\t$SUSPENDED_DB\t$SUSPENDED_CRON\t"
@@ -136,7 +141,8 @@ csv_list() {
136141
echo -n "USER,NAME,PACKAGE,WEB_TEMPLATE,BACKEND_TEMPLATE,"
137142
echo -n "PROXY_TEMPLATE,DNS_TEMPLATE,WEB_DOMAINS,WEB_ALIASES,"
138143
echo -n "DNS_DOMAINS,DNS_RECORDS,MAIL_DOMAINS,MAIL_ACCOUNTS,"
139-
echo -n "DATABASES,CRON_JOBS,DISK_QUOTA,BANDWIDTH,NS,HOME,SHELL,"
144+
echo -n "DATABASES,CRON_JOBS,DISK_QUOTA,CPU_QUOTA,CPU_QUOTA_PERIOD,"
145+
echo -n "MEMORY_LIMIT,SWAP_LIMIT,BANDWIDTH,NS,HOME,SHELL,"
140146
echo -n "BACKUPS,CONTACT,CRON_REPORTS,RKEY,ROLE,SUSPENDED,SUSPENDED_USERS,"
141147
echo -n "SUSPENDED_WEB,SUSPENDED_DNS,SUSPENDED_MAIL,SUSPENDED_DB,"
142148
echo -n "SUSPENDED_CRON,IP_AVAIL,IP_OWNED,U_USERS,U_DISK,U_DISK_DIRS,"
@@ -153,7 +159,8 @@ csv_list() {
153159
echo -n "$BACKEND_TEMPLATE,$PROXY_TEMPLATE,$DNS_TEMPLATE,"
154160
echo -n "$WEB_DOMAINS,$WEB_ALIASES,$DNS_DOMAINS,$DNS_RECORDS,"
155161
echo -n "$MAIL_DOMAINS,$MAIL_ACCOUNTS,$DATABASES,$CRON_JOBS,"
156-
echo -n "$DISK_QUOTA,$BANDWIDTH,\"$NS\",$HOME,$SHELL,$BACKUPS,"
162+
echo -n "$DISK_QUOTA,$CPU_QUOTA,$CPU_QUOTA_PERIOD,$MEMORY_LIMIT,"
163+
echo -n "$SWAP_LIMIT,$BANDWIDTH,\"$NS\",$HOME,$SHELL,$BACKUPS,"
157164
echo -n "$CONTACT,$CRON_REPORTS,\"$RKEY\",$ROLE,$SUSPENDED,"
158165
echo -n "$SUSPENDED_USERS,$SUSPENDED_WEB,$SUSPENDED_DNS,"
159166
echo -n "$SUSPENDED_MAIL,$SUSPENDED_DB,$SUSPENDED_CRON,$IP_AVAIL,"

web/templates/pages/add_package.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@
278278
</div>
279279
</div>
280280
</details>
281-
<details class="collapse" id="system-resources-options">
281+
282+
<?php if ($_SESSION['RESOURCES_LIMIT'] == 'yes') { ?>
283+
<details class="collapse" id="system-resources-options">
282284
<summary class="collapse-header">
283285
<?= _("System Resources") ?>
284286
</summary>
@@ -336,6 +338,7 @@
336338
</div>
337339
</div>
338340
</details>
341+
<?php } ?>
339342
</div>
340343

341344
</form>

web/templates/pages/edit_package.php

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -289,64 +289,67 @@ class="<?= $v_status ?>"
289289
</div>
290290
</details>
291291

292-
<details class="collapse" id="system-resources-options">
293-
<summary class="collapse-header">
294-
<?= _("System Resources") ?>
295-
</summary>
296-
<div class="collapse-content">
297-
<div class="u-mb10">
298-
<label for="cfs_quota" class="form-label">
299-
<?= _("CPU Quota (in %)") ?>
300-
</label>
301-
<div class="u-pos-relative">
302-
<input type="text" class="form-control" name="v_cpu_quota" id="v_cpu_quota" value="<?= htmlentities(trim($v_cpu_quota, "'")) ?>">
303-
<button type="button" class="unlimited-toggle js-unlimited-toggle" title="<?= _("Unlimited") ?>">
304-
<i class="fas fa-infinity"></i>
305-
</button>
292+
<?php if ($_SESSION['RESOURCES_LIMIT'] == 'yes') { ?>
293+
<details class="collapse" id="system-resources-options">
294+
<summary class="collapse-header">
295+
<?= _("System Resources") ?>
296+
</summary>
297+
<div class="collapse-content">
298+
<div class="u-mb10">
299+
<label for="cfs_quota" class="form-label">
300+
<?= _("CPU Quota (in %)") ?>
301+
</label>
302+
<div class="u-pos-relative">
303+
<input type="text" class="form-control" name="v_cpu_quota" id="v_cpu_quota" value="<?= htmlentities(trim($v_cpu_quota, "'")) ?>">
304+
<button type="button" class="unlimited-toggle js-unlimited-toggle" title="<?= _("Unlimited") ?>">
305+
<i class="fas fa-infinity"></i>
306+
</button>
307+
</div>
308+
<small class="form-text text-muted"><?= _("CPUQuota=20% ensures that the executed processes will never get more than 20% CPU time on one CPU.") ?></small>
306309
</div>
307-
<small class="form-text text-muted"><?= _("CPUQuota=20% ensures that the executed processes will never get more than 20% CPU time on one CPU.") ?></small>
308-
</div>
309310

310-
<div class="u-mb10">
311-
<label for="cfs_period" class="form-label">
312-
<?= _("CPU Quota Period (in ms for milliseconds or s for seconds.)") ?>
313-
</label>
314-
<div class="u-pos-relative">
315-
<input type="text" class="form-control" name="v_cpu_quota_period" id="v_cpu_quota_period" value="<?= htmlentities(trim($v_cpu_quota_period, "'")) ?>">
316-
<button type="button" class="unlimited-toggle js-unlimited-toggle" title="<?= _("Unlimited") ?>">
317-
<i class="fas fa-infinity"></i>
318-
</button>
311+
<div class="u-mb10">
312+
<label for="cfs_period" class="form-label">
313+
<?= _("CPU Quota Period (in ms for milliseconds or s for seconds.)") ?>
314+
</label>
315+
<div class="u-pos-relative">
316+
<input type="text" class="form-control" name="v_cpu_quota_period" id="v_cpu_quota_period" value="<?= htmlentities(trim($v_cpu_quota_period, "'")) ?>">
317+
<button type="button" class="unlimited-toggle js-unlimited-toggle" title="<?= _("Unlimited") ?>">
318+
<i class="fas fa-infinity"></i>
319+
</button>
320+
</div>
321+
<small class="form-text text-muted"><?= _("CPUQuotaPeriodSec=10ms to request that the CPU quota is measured in periods of 10ms.") ?></small>
319322
</div>
320-
<small class="form-text text-muted"><?= _("CPUQuotaPeriodSec=10ms to request that the CPU quota is measured in periods of 10ms.") ?></small>
321-
</div>
322323

323-
<div class="u-mb10">
324-
<label for="memory_limit" class="form-label">
325-
<?= _("Memory Limit (in bytes or with units like '2G')") ?>
326-
</label>
327-
<div class="u-pos-relative">
328-
<input type="text" class="form-control" name="v_memory_limit" id="v_memory_limit" value="<?= htmlentities(trim($v_memory_limit, "'")) ?>">
329-
<button type="button" class="unlimited-toggle js-unlimited-toggle" title="<?= _("Unlimited") ?>">
330-
<i class="fas fa-infinity"></i>
331-
</button>
324+
<div class="u-mb10">
325+
<label for="memory_limit" class="form-label">
326+
<?= _("Memory Limit (in bytes or with units like '2G')") ?>
327+
</label>
328+
<div class="u-pos-relative">
329+
<input type="text" class="form-control" name="v_memory_limit" id="v_memory_limit" value="<?= htmlentities(trim($v_memory_limit, "'")) ?>">
330+
<button type="button" class="unlimited-toggle js-unlimited-toggle" title="<?= _("Unlimited") ?>">
331+
<i class="fas fa-infinity"></i>
332+
</button>
333+
</div>
334+
<small class="form-text text-muted"><?= _("Takes a memory size in bytes. If the value is suffixed with K, M, G or T, the specified memory size is parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively") ?></small>
332335
</div>
333-
<small class="form-text text-muted"><?= _("Takes a memory size in bytes. If the value is suffixed with K, M, G or T, the specified memory size is parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively") ?></small>
334-
</div>
335336

336-
<div class="u-mb10">
337-
<label for="swap_limit" class="form-label">
338-
<?= _("Swap Limit (in bytes or with units like '2G')") ?>
339-
</label>
340-
<div class="u-pos-relative">
341-
<input type="text" class="form-control" name="v_swap_limit" id="v_swap_limit" value="<?= htmlentities(trim($v_swap_limit, "'")) ?>">
342-
<button type="button" class="unlimited-toggle js-unlimited-toggle" title="<?= _("Unlimited") ?>">
343-
<i class="fas fa-infinity"></i>
344-
</button>
337+
<div class="u-mb10">
338+
<label for="swap_limit" class="form-label">
339+
<?= _("Swap Limit (in bytes or with units like '2G')") ?>
340+
</label>
341+
<div class="u-pos-relative">
342+
<input type="text" class="form-control" name="v_swap_limit" id="v_swap_limit" value="<?= htmlentities(trim($v_swap_limit, "'")) ?>">
343+
<button type="button" class="unlimited-toggle js-unlimited-toggle" title="<?= _("Unlimited") ?>">
344+
<i class="fas fa-infinity"></i>
345+
</button>
346+
</div>
347+
<small class="form-text text-muted"><?= _("Takes a swap size in bytes. If the value is suffixed with K, M, G or T, the specified swap size is parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively") ?></small>
345348
</div>
346-
<small class="form-text text-muted"><?= _("Takes a swap size in bytes. If the value is suffixed with K, M, G or T, the specified swap size is parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively") ?></small>
347349
</div>
348-
</div>
349-
</details>
350+
</details>
351+
<?php } ?>
352+
350353
</div>
351354

352355
</form>

0 commit comments

Comments
 (0)