mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-19 16:35:52 +03:00
fix(db-run): проверять ранний выход процесса, возвращать PID, маскировать секреты
Раньше db-run безусловно печатал «launched» сразу после запуска, не отличая успешный фоновый старт от мгновенного падения (нет дисплея/лицензии). Теперь короткое контрольное окно ловит ранний выход → ненулевой код без «launched», иначе печатается PID. Строка Running маскирует /N и /P (не светить пароль); маскировка привязана к границе токена, чтобы не портить путь с сегментом /N|/P. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
89a0081403
commit
e85fc538f6
@@ -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
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
|
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
|
||||||
<#
|
<#
|
||||||
@@ -165,7 +165,25 @@ if ($URL) {
|
|||||||
|
|
||||||
$argString += " /DisableStartupDialogs"
|
$argString += " /DisableStartupDialogs"
|
||||||
|
|
||||||
# --- Execute (background, no wait) ---
|
# --- Execute (background) ---
|
||||||
Write-Host "Running: 1cv8.exe $argString"
|
# Mask credentials (/N, /P) before printing the command line — never leak secrets.
|
||||||
Start-Process -FilePath $V8Path -ArgumentList $argString
|
# 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
|
Write-Host "1C:Enterprise launched" -ForegroundColor Green
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/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
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -9,6 +9,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
def _find_project_v8path():
|
def _find_project_v8path():
|
||||||
@@ -131,9 +132,24 @@ def main():
|
|||||||
|
|
||||||
arguments.append("/DisableStartupDialogs")
|
arguments.append("/DisableStartupDialogs")
|
||||||
|
|
||||||
# --- Execute (background, no wait) ---
|
# --- Execute (background) ---
|
||||||
print(f"Running: 1cv8.exe {' '.join(arguments)}")
|
# Mask credentials (/N, /P) before printing the command line — never leak secrets.
|
||||||
subprocess.Popen([v8path] + arguments)
|
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")
|
print("1C:Enterprise launched")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user