mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Add code samples to Queue config screen
This commit is contained in:
parent
d4cd5e3d75
commit
097cecece8
6 changed files with 124 additions and 2 deletions
|
|
@ -30,5 +30,5 @@ else
|
|||
}
|
||||
|
||||
// The rest of the work will be done by the Queue class.
|
||||
$timeout = config('queue.interval') ?? 60;
|
||||
$timeout = (config('queue.interval') ?? 1) * 60;
|
||||
Rhymix\Framework\Queue::process($timeout);
|
||||
|
|
|
|||
|
|
@ -299,6 +299,13 @@ $lang->cmd_queue_config_keys['port'] = 'Port';
|
|||
$lang->cmd_queue_config_keys['user'] = 'User';
|
||||
$lang->cmd_queue_config_keys['pass'] = 'Password';
|
||||
$lang->cmd_queue_config_keys['dbnum'] = 'DB Number';
|
||||
$lang->msg_queue_instructions['same_as_php'] = '(same as PHP)';
|
||||
$lang->msg_queue_instructions['crontab1'] = 'Log into the server as the <code>%s</code> account and run <code>crontab -e</code> to paste the following content into your crontab. (DO NOT run it as root!)<br>The <code>%s</code> directory in the example should be replaced with a path where logs can be recorded.';
|
||||
$lang->msg_queue_instructions['crontab2'] = 'If you change the calling interval below, the crontab interval must be adjusted accordingly.';
|
||||
$lang->msg_queue_instructions['webcron'] = 'Configure an external cron service to make a GET request to the following URL every minute, or following the interval set below.<br>Check your logs to make sure that the cron service is reaching your website.';
|
||||
$lang->msg_queue_instructions['systemd1'] = 'Put the following content in <code>/etc/systemd/system/rhymix-queue.service</code>';
|
||||
$lang->msg_queue_instructions['systemd2'] = 'Put the following content in <code>/etc/systemd/system/rhymix-queue.timer</code>';
|
||||
$lang->msg_queue_instructions['systemd3'] = 'Execute the following commands to enable the timer, and monitor your journal to make sure that it is operating as scheduled.';
|
||||
$lang->autoinstall = 'EasyInstall';
|
||||
$lang->last_week = 'Last Week';
|
||||
$lang->this_week = 'This Week';
|
||||
|
|
|
|||
|
|
@ -295,6 +295,13 @@ $lang->cmd_queue_config_keys['port'] = '포트';
|
|||
$lang->cmd_queue_config_keys['user'] = '아이디';
|
||||
$lang->cmd_queue_config_keys['pass'] = '암호';
|
||||
$lang->cmd_queue_config_keys['dbnum'] = 'DB 번호';
|
||||
$lang->msg_queue_instructions['same_as_php'] = 'PHP를 실행하는 계정과 동일한';
|
||||
$lang->msg_queue_instructions['crontab1'] = '%s 계정으로 서버에 로그인하여 <code>crontab -e</code> 명령을 실행한 후, 아래의 내용을 붙여넣으십시오. (root 권한으로 실행하지 마십시오.)<br>예제의 <code>%s</code> 디렉토리는 로그를 기록할 수 있는 경로로 변경하여 사용하십시오.';
|
||||
$lang->msg_queue_instructions['crontab2'] = '스크립트 호출 간격을 변경할 경우, 설정에 맞추어 crontab 실행 간격도 조절하여야 합니다.';
|
||||
$lang->msg_queue_instructions['webcron'] = '아래의 URL을 1분 간격 또는 아래에서 설정한 호출 간격에 맞추어 GET으로 호출하도록 합니다.<br>웹크론 서비스가 방화벽이나 CDN 등에 의해 차단되지 않도록 주의하고, 정상적으로 호출되는지 서버 로그를 확인하십시오.';
|
||||
$lang->msg_queue_instructions['systemd1'] = '<code>/etc/systemd/system/rhymix-queue.service</code> 파일에 아래와 같은 내용을 넣습니다.';
|
||||
$lang->msg_queue_instructions['systemd2'] = '<code>/etc/systemd/system/rhymix-queue.timer</code> 파일에 아래와 같은 내용을 넣습니다.';
|
||||
$lang->msg_queue_instructions['systemd3'] = '아래의 명령을 실행하여 타이머를 활성화하고, 정상 작동하는지 모니터링하십시오.';
|
||||
$lang->autoinstall = '쉬운 설치';
|
||||
$lang->last_week = '지난주';
|
||||
$lang->this_week = '이번주';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<config autoescape="on" />
|
||||
|
||||
<include target="config_header.html" />
|
||||
<load target="css/queue_config.scss" />
|
||||
<load target="js/queue_config.js" />
|
||||
|
||||
<div class="message">
|
||||
|
|
@ -96,6 +97,69 @@
|
|||
|
||||
<h2>{$lang->cmd_queue_call_script}</h2>
|
||||
|
||||
<div class="queue-script-setup">
|
||||
<ul class="qss-tabs x_nav x_nav-tabs">
|
||||
<li class="x_active"><a href="#" data-value="crontab">crontab</a></li>
|
||||
<li><a href="#" data-value="webcron">webcron</a></li>
|
||||
<li><a href="#" data-value="systemd-timer">systemd timer</a></li>
|
||||
</ul>
|
||||
<div class="qss-content crontab active">
|
||||
{@
|
||||
if (function_exists('posix_getpwuid') && function_exists('posix_getuid')):
|
||||
$user_info = posix_getpwuid(posix_getuid());
|
||||
if (!empty($user_info['dir'])):
|
||||
$user_info['dir'] .= DIRECTORY_SEPARATOR;
|
||||
endif;
|
||||
else:
|
||||
$user_info = [];
|
||||
$user_info['name'] = $lang->msg_queue_instructions['same_as_php'];
|
||||
endif;
|
||||
}
|
||||
<p class="qss-instruction">
|
||||
{sprintf($lang->msg_queue_instructions['crontab1'], $user_info['name'] ?? 'PHP', $user_info['dir'] . 'logs')|noescape}
|
||||
</p>
|
||||
<pre><code>* * * * * php {\RX_BASEDIR}index.php common.cron >> {$user_info['dir']}logs{\DIRECTORY_SEPARATOR}queue.log 2>&1</code></pre>
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['crontab2']|noescape}
|
||||
</p>
|
||||
</div>
|
||||
<div class="qss-content webcron">
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['webcron']|noescape}
|
||||
</p>
|
||||
<pre><code class="webcron-url">{getFullUrl('')}common/scripts/cron.php?key={config('queue.key')}</code></pre>
|
||||
</div>
|
||||
<div class="qss-content systemd-timer">
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['systemd1']|noescape}
|
||||
</p>
|
||||
<pre><code>[Unit]
|
||||
Description=Rhymix Queue Service
|
||||
|
||||
[Service]
|
||||
ExecStart=php {\RX_BASEDIR}index.php common.cron
|
||||
User={$user_info['name']}</code></pre>
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['systemd2']|noescape}
|
||||
</p>
|
||||
<pre><code>[Unit]
|
||||
Description=Rhymix Queue Timer
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* *:*:00
|
||||
Unit=rhymix-queue.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target</code></pre>
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['systemd3']|noescape}
|
||||
</p>
|
||||
<pre><code>systemctl daemon-reload
|
||||
systemctl start rhymix-queue.timer
|
||||
systemctl enable rhymix-queue.timer</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="queue_key">{$lang->cmd_queue_webcron_key}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
27
modules/admin/tpl/css/queue_config.scss
Normal file
27
modules/admin/tpl/css/queue_config.scss
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
.queue-script-setup {
|
||||
.qss-content {
|
||||
display: none;
|
||||
&.active {
|
||||
display: block;
|
||||
border: 1px solid #ddd;
|
||||
border-top: 0;
|
||||
margin-top: -20px;
|
||||
padding: 20px 12px 10px 12px;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.qss-instruction {
|
||||
margin-bottom: 10px;
|
||||
code {
|
||||
color: #333;
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
padding: 0 1px;
|
||||
}
|
||||
}
|
||||
.pre {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
$(function() {
|
||||
|
||||
$("#queue_driver").on("change", function() {
|
||||
var selected_driver = $(this).val();
|
||||
const selected_driver = $(this).val();
|
||||
$(this).parents("section").find("div.x_control-group.hidden-by-default, p.x_help-block.hidden-by-default").each(function() {
|
||||
if ($(this).hasClass("show-for-" + selected_driver)) {
|
||||
$(this).show();
|
||||
|
|
@ -12,5 +12,22 @@
|
|||
});
|
||||
}).triggerHandler("change");
|
||||
|
||||
$("#queue_key").on('change keyup paste', function() {
|
||||
const key = encodeURIComponent(String($(this).val()));
|
||||
$('.webcron-url').text($('.webcron-url').text().replace(/\?key=[a-zA-Z0-9]+/g, '?key=' + key));
|
||||
});
|
||||
|
||||
const qss = $('.queue-script-setup');
|
||||
const qss_tabs = qss.find('.qss-tabs');
|
||||
const qss_content = qss.find('.qss-content');
|
||||
qss_tabs.on('click', 'a', function(event) {
|
||||
const selected_tab = $(this).data('value');
|
||||
qss_tabs.find('li').removeClass('x_active');
|
||||
$(this).parent().addClass('x_active');
|
||||
qss_content.removeClass('active');
|
||||
qss_content.filter('.' + selected_tab).addClass('active');
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue