Repository navigation
fix(cli): Windows 守护进程外壳改用 cmd 重定向输出 - #165
Merged
Merged
Conversation
Windows PowerShell 5.1 中 OutputDataReceived 脚本块回调运行在没有 Runspace 的线程池线程上,守护进程第一次输出就会抛 PSInvalidOperationException 使外壳崩溃,守护进程及其服务随之退出。改由 cmd.exe 把输出追加到 daemon.log。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
10/27 11:29 dogelake 整个实例(BDS、db、qq、bluemap)无预兆停服,桌面端提示"游戏服务器数据服务暂不可用"。
服务器崩溃报告显示 11:29:39、11:29:50 两次
powershell.exe崩溃,签名为PSInvalidOperation@ScriptBlock.GetContextFromTLS。原因是launchWindowsOutsideSession的外壳脚本用 PowerShell 脚本块注册OutputDataReceived/ErrorDataReceived:Windows PowerShell 5.1 中这些回调运行在没有 Runspace 的线程池线程上,守护进程一输出就让外壳崩溃,守护进程及其服务随之退出。daemon.log自 10/15 后再无写入,也印证了这一点。修改
cmd.exe /d /s /c "... --daemon >> daemon.log 2>&1",不再在 PowerShell 中接管输出。SFMC_DAEMON_LOG留给守护进程"的原逻辑。验证
本机经 WMI 实际拉起假守护进程(路径含空格与
&),标准输出和标准错误各 20 行:SFMC_DAEMON_LOG。EBUSY,守护进程退出后立即释放。平台切换中的waitDaemonLogAppendable发生在旧守护进程退出之后,不受影响。pnpm run typecheck通过。