Implement logging for Windows launch arguments in single instance management
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Added `logWindowsLaunchArgs` function to log launch arguments and sources for better debugging on Windows. - Integrated logging into `ensureSingleInstanceLock` and instance handling to provide insights during instance management. - Enhanced existing logging to include context-specific messages for improved clarity in the Windows environment.
This commit is contained in:
parent
93df523b7c
commit
37593d73ce
@ -1,16 +1,28 @@
|
|||||||
import {
|
import {
|
||||||
captureLaunchUrl,
|
captureLaunchUrl,
|
||||||
closeSingleInstanceServer,
|
closeSingleInstanceServer,
|
||||||
ensureSingleInstanceLock
|
ensureSingleInstanceLock,
|
||||||
|
logWindowsLaunchArgs
|
||||||
} from '../desktop/single-instance.js'
|
} from '../desktop/single-instance.js'
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
logWindowsLaunchArgs('index-before-lock')
|
||||||
|
}
|
||||||
|
|
||||||
const launchUrl = captureLaunchUrl()
|
const launchUrl = captureLaunchUrl()
|
||||||
const gotSingleInstanceLock = await ensureSingleInstanceLock({ launchUrl })
|
const gotSingleInstanceLock = await ensureSingleInstanceLock({ launchUrl })
|
||||||
|
|
||||||
if (!gotSingleInstanceLock) {
|
if (!gotSingleInstanceLock) {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
console.log('[launch-args][index] exiting secondary instance')
|
||||||
|
}
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
console.log('[launch-args][index] acquired single instance lock')
|
||||||
|
}
|
||||||
|
|
||||||
const { createAppRpc } = await import('../desktop/rpc.js')
|
const { createAppRpc } = await import('../desktop/rpc.js')
|
||||||
const {
|
const {
|
||||||
registerGlobalShortcuts,
|
registerGlobalShortcuts,
|
||||||
|
|||||||
@ -162,6 +162,19 @@ function collectLaunchSources() {
|
|||||||
return sources
|
return sources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function logWindowsLaunchArgs(context = 'startup') {
|
||||||
|
if (process.platform !== 'win32') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const launchSources = getWindowsLaunchSources()
|
||||||
|
const launchUrl = captureLaunchUrl()
|
||||||
|
|
||||||
|
console.log(`[launch-args][${context}] process.argv:`, process.argv)
|
||||||
|
console.log(`[launch-args][${context}] launch sources:`, launchSources)
|
||||||
|
console.log(`[launch-args][${context}] captured url:`, launchUrl ?? null)
|
||||||
|
}
|
||||||
|
|
||||||
export function captureLaunchUrl() {
|
export function captureLaunchUrl() {
|
||||||
const argvUrl = findProtocolUrl(process.argv)
|
const argvUrl = findProtocolUrl(process.argv)
|
||||||
if (argvUrl) {
|
if (argvUrl) {
|
||||||
@ -249,6 +262,11 @@ function dispatchMessage(message) {
|
|||||||
const resolved = resolveIncomingMessage(message)
|
const resolved = resolveIncomingMessage(message)
|
||||||
if (!resolved) return
|
if (!resolved) return
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
console.log('[launch-args][dispatch]', message)
|
||||||
|
console.log('[launch-args][dispatch] resolved:', resolved)
|
||||||
|
}
|
||||||
|
|
||||||
if (!handlers.onDeepLink && !handlers.onFocus) {
|
if (!handlers.onDeepLink && !handlers.onFocus) {
|
||||||
pendingMessages.push(resolved)
|
pendingMessages.push(resolved)
|
||||||
return
|
return
|
||||||
@ -364,8 +382,14 @@ export async function ensureSingleInstanceLock({ launchUrl } = {}) {
|
|||||||
|
|
||||||
const payload = buildLaunchPayload(launchUrl)
|
const payload = buildLaunchPayload(launchUrl)
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
logWindowsLaunchArgs('ensure-single-instance-lock')
|
||||||
|
console.log('[launch-args][single-instance] payload:', payload)
|
||||||
|
}
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
if (await forwardToRunningInstance(payload)) {
|
if (await forwardToRunningInstance(payload)) {
|
||||||
|
console.log('[launch-args][single-instance] forwarded to running instance')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user