Article: - rename the deployment section to "Развёртывание через config/services.ini" - keep only first-level sections in the table of contents, drop the archive entry - add the warning block and the archive table in the series format - rename screenshots to meaningful English names Publishing helpers (docs/publish): - build_article_html.py builds the HTML fragment for the site editor with anchored headings, linked table of contents, captions and code blocks - code/ holds each code block as a separate file, description.txt the short description Code: - static/script.js: bump version to 0.3.0 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
void OnStart()
| |
{
| |
PrintFormat("Запуск сервиса для экземпляра '%s'", InstanceFolder());
| |
| |
// Разброс интервала, чтобы записи разных сервисов не совпадали по фазе
| |
MathSrand((int)TimeLocal() + (int)GetTickCount());
| |
| |
const int interval_ms = InpIntervalSec * 1000;
| |
| |
while(!IsStopped())
| |
{
| |
// 1. Подключаемся к базе, если ещё не подключены
| |
if(g_db == INVALID_HANDLE)
| |
{
| |
if(!OpenDatabase())
| |
{
| |
Sleep(interval_ms);
| |
continue;
| |
}
| |
g_terminal_id = -1;
| |
}
| |
| |
// 2. Регистрируем терминал, если ещё не зарегистрирован
| |
if(g_terminal_id < 0)
| |
{
| |
g_terminal_id = RegisterTerminal();
| |
if(g_terminal_id < 0)
| |
{
| |
Sleep(interval_ms);
| |
continue;
| |
}
| |
}
| |
| |
// 3. Записываем текущее состояние
| |
if(!StoreState())
| |
{
| |
g_skipped++;
| |
if(g_skipped % 10 == 0)
| |
PrintFormat("Пропущено записей: %d, последняя ошибка: %d",
| |
g_skipped, GetLastError());
| |
}
| |
| |
// 4. Ждём до следующей итерации, добавляя небольшой случайный разброс
| |
int pause = interval_ms;
| |
if(InpJitterMs > 0)
| |
pause += (int)(MathRand() % InpJitterMs);
| |
Sleep(pause);
| |
}
| |
| |
if(g_db != INVALID_HANDLE)
| |
DatabaseClose(g_db);
| |
}
|