Add notice and process count to Queue config screen

This commit is contained in:
Kijin Sung 2024-10-10 09:43:41 +09:00
parent a2a1f3bcc6
commit d4cd5e3d75
4 changed files with 26 additions and 0 deletions

View file

@ -91,6 +91,13 @@ class Queue extends Base
throw new Exception('4444');
}
// Validate the process count.
$process_count = intval($vars->queue_process_count ?? 1);
if ($process_count < 1 || $process_count > 10)
{
throw new Exception('4444');
}
// Validate the key.
$key = trim($vars->queue_key ?? '');
if (strlen($key) < 16 || !ctype_alnum($key))
@ -102,6 +109,7 @@ class Queue extends Base
Config::set("queue.enabled", $enabled);
Config::set("queue.driver", $driver);
Config::set("queue.interval", $interval);
Config::set("queue.process_count", $process_count);
Config::set("queue.key", $key);
Config::set("queue.$driver", $driver_config);
if (!Config::save())

View file

@ -283,12 +283,15 @@ $lang->og_extract_images_fallback = 'Use site default image only';
$lang->og_extract_hashtags = 'Extract Hashtags from Document';
$lang->og_use_nick_name = 'Include Author Name';
$lang->og_use_timestamps = 'Include Timestamps';
$lang->cmd_queue_description = 'Improve response times by processing time-consuming tasks, such as sending notifications, asynchronously.<br>This is an experimental feature. It may not be stable depending on your hosting environment.';
$lang->cmd_queue_enabled = 'Use Task Queue';
$lang->cmd_queue_enabled_help = 'The task queue will stop accepting new tasks if you uncheck the above.';
$lang->cmd_queue_driver = 'Queue Driver';
$lang->cmd_queue_driver_help = 'Select the driver for the task queue that suits your hosting environment and website needs.<br>Some drivers such as Redis will need the corresponding program to be installed on the server.';
$lang->cmd_queue_interval = 'Calling Interval';
$lang->cmd_queue_interval_help = 'Use a scheduler such as crontab or systemd timer to call the script on a set interval.<br>All tasks are processed as soon as possible regardless of the interval, but a short interval means quick recovery from any error.<br>For web-based cron, this should not exceed the max_execution_time setting in php.ini.<br>The max_execution_time on this server is %d seconds.';
$lang->cmd_queue_process_count = 'Process Count';
$lang->cmd_queue_process_count_help = 'Use multiple processes to increase throughput. This may increase server load significantly.<br>Keep a value of 1 unless you have a high-performance dedicated server.<br>Multiprocessing is not supported when using web-based cron.';
$lang->cmd_queue_call_script = 'Processing Script';
$lang->cmd_queue_webcron_key = 'Webcron Auth Key';
$lang->cmd_queue_config_keys['host'] = 'Host';

View file

@ -279,12 +279,15 @@ $lang->og_extract_images_fallback = '사이트 대표 이미지 사용';
$lang->og_extract_hashtags = '본문에서 해시태그 추출';
$lang->og_use_nick_name = '글 작성자 이름 표시';
$lang->og_use_timestamps = '글 작성/수정 시각 표시';
$lang->cmd_queue_description = '메일 발송, 푸시알림 등 시간이 오래 걸리거나 외부 서비스와 연동하는 작업을 비동기 처리하여 응답 속도를 개선합니다.<br>실험적인 기능입니다. 호스팅 환경에 따라서는 안정적으로 작동하지 않을 수도 있습니다.';
$lang->cmd_queue_enabled = '비동기 작업 사용';
$lang->cmd_queue_enabled_help = '체크를 해제하면 더이상 작업을 접수하지 않습니다.';
$lang->cmd_queue_driver = '비동기 드라이버';
$lang->cmd_queue_driver_help = '비동기 작업을 관리할 방법을 설정합니다. 호스팅 환경과 사이트의 필요에 맞추어 선택하세요.<br>Redis 등 일부 드라이버는 서버에 해당 기능이 설치되어 있어야 사용할 수 있습니다.';
$lang->cmd_queue_interval = '호출 간격';
$lang->cmd_queue_interval_help = 'crontab, systemd timer, 웹크론 등을 사용하여 일정한 주기로 스크립트를 호출해 주십시오.<br>모든 비동기 작업은 호출 간격과 무관하게 실시간으로 처리되나, 호출 간격이 짧으면 장애 발생시 신속하게 복구됩니다.<br>웹크론 사용시에는 php.ini의 실행 시간 제한을 초과하지 않는 것이 좋습니다.<br>이 서버의 max_execution_time은 %d초로 설정되어 있습니다.';
$lang->cmd_queue_process_count = '프로세스 갯수';
$lang->cmd_queue_process_count_help = '여러 개의 프로세스를 동시에 실행하여 처리 용량을 늘립니다. 서버 부하가 증가할 수 있습니다.<br>고성능 단독서버가 아니라면 1을 유지하시기 바랍니다.<br>웹크론으로 호출한 경우에는 멀티프로세싱을 지원하지 않습니다.';
$lang->cmd_queue_call_script = '작업 처리 스크립트';
$lang->cmd_queue_webcron_key = '웹크론 인증키';
$lang->cmd_queue_config_keys['host'] = '호스트';

View file

@ -3,6 +3,10 @@
<include target="config_header.html" />
<load target="js/queue_config.js" />
<div class="message">
<p>{$lang->cmd_queue_description}</p>
</div>
<div cond="!empty($XE_VALIDATOR_MESSAGE) && $XE_VALIDATOR_ID == 'modules/admin/tpl/config_queue/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>
@ -109,6 +113,14 @@
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="queue_process_count">{$lang->cmd_queue_process_count}</label>
<div class="x_controls">
<input type="number" name="queue_process_count" id="queue_process_count" min="1" max="10" value="{config('queue.process_count') ?: 1}" />
<p class="x_help-block">{$lang->cmd_queue_process_count_help}</p>
</div>
</div>
</section>
<div class="x_clearfix btnArea">