Skip to content

Commit

Permalink
WSL: Enable debug logging for wsl-init
Browse files Browse the repository at this point in the history
If debug mode is set, we enable debug logging for wsl-init (and therefore
network-setup).

Signed-off-by: Mark Yen <mark.yen@suse.com>
  • Loading branch information
mook-as committed Dec 24, 2024
1 parent a658f04 commit 239029c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/rancher-desktop/assets/scripts/wsl-init
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [ $$ -ne "1" ]; then
# from WSL.
exec /usr/local/bin/network-setup --logfile "$NETWORK_SETUP_LOG" \
--vm-switch-path /usr/local/bin/vm-switch --vm-switch-logfile \
"$VM_SWITCH_LOG" --unshare-arg "${0}"
"$VM_SWITCH_LOG" ${RD_DEBUG:+-debug} --unshare-arg "${0}"
fi

# Mark directories that we will need to bind mount as shared mounts.
Expand Down
17 changes: 11 additions & 6 deletions pkg/rancher-desktop/backend/wsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,15 +1041,20 @@ export default class WSLBackend extends events.EventEmitter implements VMBackend

// The process should already be gone by this point, but make sure.
this.process?.kill('SIGTERM');
const env: Record<string, string> = {
...process.env,
WSLENV: `${ process.env.WSLENV }:DISTRO_DATA_DIRS:LOG_DIR/p:RD_DEBUG`,
DISTRO_DATA_DIRS: DISTRO_DATA_DIRS.join(':'),
LOG_DIR: paths.logs,
};

if (this.debug) {
env.RD_DEBUG = '1';
}
this.process = childProcess.spawn('wsl.exe',
['--distribution', INSTANCE_NAME, '--exec', '/usr/local/bin/wsl-init'],
{
env: {
...process.env,
WSLENV: `${ process.env.WSLENV }:DISTRO_DATA_DIRS:LOG_DIR/p`,
DISTRO_DATA_DIRS: DISTRO_DATA_DIRS.join(':'),
LOG_DIR: paths.logs,
},
env,
stdio: ['ignore', 'pipe', 'pipe'],
windowsHide: true,
});
Expand Down

0 comments on commit 239029c

Please sign in to comment.