From e85fc538f60e8c5e3b7628510367584b5ae96db4 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sun, 19 Jul 2026 18:51:50 +0300 Subject: [PATCH] =?UTF-8?q?fix(db-run):=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D1=8F=D1=82=D1=8C=20=D1=80=D0=B0=D0=BD=D0=BD=D0=B8=D0=B9?= =?UTF-8?q?=20=D0=B2=D1=8B=D1=85=D0=BE=D0=B4=20=D0=BF=D1=80=D0=BE=D1=86?= =?UTF-8?q?=D0=B5=D1=81=D1=81=D0=B0,=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80?= =?UTF-8?q?=D0=B0=D1=89=D0=B0=D1=82=D1=8C=20PID,=20=D0=BC=D0=B0=D1=81?= =?UTF-8?q?=D0=BA=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D0=BA=D1=80=D0=B5=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Раньше db-run безусловно печатал «launched» сразу после запуска, не отличая успешный фоновый старт от мгновенного падения (нет дисплея/лицензии). Теперь короткое контрольное окно ловит ранний выход → ненулевой код без «launched», иначе печатается PID. Строка Running маскирует /N и /P (не светить пароль); маскировка привязана к границе токена, чтобы не портить путь с сегментом /N|/P. Co-Authored-By: Claude Opus 4.8 --- .claude/skills/db-run/scripts/db-run.ps1 | 26 ++++++++++++++++++++---- .claude/skills/db-run/scripts/db-run.py | 24 ++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.claude/skills/db-run/scripts/db-run.ps1 b/.claude/skills/db-run/scripts/db-run.ps1 index c040db37..3806cbe9 100644 --- a/.claude/skills/db-run/scripts/db-run.ps1 +++ b/.claude/skills/db-run/scripts/db-run.ps1 @@ -1,4 +1,4 @@ -# db-run v1.2 — Launch 1C:Enterprise +# db-run v1.3 — Launch 1C:Enterprise # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # NB: *nix-раскладку платформы (/opt/1cv8//1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. <# @@ -165,7 +165,25 @@ if ($URL) { $argString += " /DisableStartupDialogs" -# --- Execute (background, no wait) --- -Write-Host "Running: 1cv8.exe $argString" -Start-Process -FilePath $V8Path -ArgumentList $argString +# --- Execute (background) --- +# Mask credentials (/N, /P) before printing the command line — never leak secrets. +# Anchor to a token boundary (whitespace before the flag) so a "/N" or "/P" that merely +# appears inside a path (e.g. ...\Program Files\..., ...\NSHIROV\...) is not mangled. +$displayArg = $argString -replace '(?<=\s)(/[NP])("[^"]*"|\S+)', '$1***' +Write-Host "Running: 1cv8.exe $displayArg" +$proc = Start-Process -FilePath $V8Path -ArgumentList $argString -PassThru + +# --- Bounded early-exit check --- +# The launch is a background GUI process, so we don't wait for completion. But a process +# that dies within the first ~1.5s never really started (bad base, no display, license) — +# report that honestly instead of a blind "launched". +$deadline = (Get-Date).AddMilliseconds(1500) +while ((Get-Date) -lt $deadline -and -not $proc.HasExited) { + Start-Sleep -Milliseconds 200 +} +if ($proc.HasExited) { + Write-Host "Error: 1C:Enterprise exited immediately (code: $($proc.ExitCode))" -ForegroundColor Red + if ($proc.ExitCode -ne 0) { exit $proc.ExitCode } else { exit 1 } +} +Write-Host "PID: $($proc.Id)" Write-Host "1C:Enterprise launched" -ForegroundColor Green diff --git a/.claude/skills/db-run/scripts/db-run.py b/.claude/skills/db-run/scripts/db-run.py index 3b1e4e74..7826a1cd 100644 --- a/.claude/skills/db-run/scripts/db-run.py +++ b/.claude/skills/db-run/scripts/db-run.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# db-run v1.2 — Launch 1C:Enterprise +# db-run v1.3 — Launch 1C:Enterprise # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse @@ -9,6 +9,7 @@ import os import re import subprocess import sys +import time def _find_project_v8path(): @@ -131,9 +132,24 @@ def main(): arguments.append("/DisableStartupDialogs") - # --- Execute (background, no wait) --- - print(f"Running: 1cv8.exe {' '.join(arguments)}") - subprocess.Popen([v8path] + arguments) + # --- Execute (background) --- + # Mask credentials (/N, /P) before printing the command line — never leak secrets. + display = [re.sub(r"^(/[NP]).+", r"\1***", a) for a in arguments] + print(f"Running: 1cv8.exe {' '.join(display)}") + proc = subprocess.Popen([v8path] + arguments) + + # --- Bounded early-exit check --- + # The launch is a background GUI process, so we don't wait for completion. But a process + # that dies within the first ~1.5s never really started (bad base, no display, license) — + # report that honestly instead of a blind "launched". + deadline = time.monotonic() + 1.5 + while time.monotonic() < deadline and proc.poll() is None: + time.sleep(0.2) + rc = proc.poll() + if rc is not None: + print(f"Error: 1C:Enterprise exited immediately (code: {rc})", file=sys.stderr) + sys.exit(rc if rc and rc > 0 else 1) + print(f"PID: {proc.pid}") print("1C:Enterprise launched")