-
Notifications
You must be signed in to change notification settings - Fork 0
fix(airc daemon): launcher cd's to cwd, skip AIRC_HOME (kills crashloop) #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4876,10 +4876,19 @@ _daemon_airc_path() { | |||||
| fi | ||||||
| } | ||||||
|
|
||||||
| # The scope the daemon will run under. If AIRC_HOME is set at install time, | ||||||
| # that's recorded in the unit/plist so future starts use the same scope. | ||||||
| # The scope the daemon will run under. Mirrors detect_scope() (line 135) | ||||||
| # so `airc daemon install` from a project dir captures THAT dir's | ||||||
| # .airc as the daemon's scope -- otherwise the daemon spawns a monitor | ||||||
| # pointed at $HOME/.airc (empty / wrong room) while the user's actual | ||||||
| # join state lives at $cwd/.airc. Joel 2026-04-28: "lol obv if it | ||||||
| # worked you would have a monitor and be online. FAIL" -- caught the | ||||||
| # scope mismatch on continuum-b69f's box. | ||||||
| _daemon_scope() { | ||||||
| echo "${AIRC_HOME:-$HOME/.airc}" | ||||||
| if [ -n "${AIRC_HOME:-}" ]; then | ||||||
| echo "$AIRC_HOME" | ||||||
| else | ||||||
| echo "$(pwd -P)/.airc" | ||||||
| fi | ||||||
| } | ||||||
|
|
||||||
| # Returns 0 if the autostart daemon (launchd / systemd unit) is installed | ||||||
|
|
@@ -5011,18 +5020,42 @@ _daemon_install_schtasks() { | |||||
|
|
||||||
| # Stage a launcher .bat in $scope. Loops with 5s pause for airc-crash | ||||||
| # auto-restart (matches launchd KeepAlive=true / systemd Restart=always). | ||||||
| # Uses `start /B` for the bash invocation so the cmd.exe wrapper | ||||||
| # doesn't pop a visible console window at logon. | ||||||
| # | ||||||
| # Why we cd into the project dir + don't set AIRC_HOME: airc's | ||||||
| # detect_scope() uses cwd to find <cwd>/.airc. Setting AIRC_HOME | ||||||
| # to a Windows-form path (C:\Users\green\continuum\.airc) makes | ||||||
| # later bash code that touches AIRC_HOME hit "no such file" on | ||||||
| # Git Bash's mixed POSIX/Windows fs view. cd'ing first + letting | ||||||
| # detect_scope work its normal way is cleaner. Joel 2026-04-28 | ||||||
| # caught the daemon crashlooping every 4s in the prior shape. | ||||||
| # | ||||||
| # bash -c (not -lc): skip login profile. Login shells re-export | ||||||
| # PATH and other vars from /etc/profile.d/* on Git Bash, which can | ||||||
| # override the env we just set in cmd. Non-login bash keeps the | ||||||
| # cmd-set env clean. | ||||||
| # | ||||||
| # Absolute Unix-form path to airc: bash with -c doesn't read | ||||||
| # ~/.bashrc, so PATH may not include ~/.local/bin. Hard-coding | ||||||
| # the resolved unix path makes the invocation independent of PATH. | ||||||
| local cwd_win airc_bin_unix | ||||||
| if command -v cygpath >/dev/null 2>&1; then | ||||||
| cwd_win=$(cygpath -w "$(pwd -P)") | ||||||
| airc_bin_unix=$(cygpath -u "$airc_bin" 2>/dev/null) | ||||||
| [ -z "$airc_bin_unix" ] && airc_bin_unix="$airc_bin" | ||||||
| else | ||||||
| cwd_win=$(printf '%s' "$(pwd -P)" | sed 's|^/\([a-z]\)/|\U\1:\\\\|; s|/|\\\\|g') | ||||||
| airc_bin_unix="$airc_bin" | ||||||
| fi | ||||||
| local launcher_bash="$scope/airc-daemon.bat" | ||||||
| cat > "$launcher_bash" <<EOF | ||||||
| @echo off | ||||||
| REM AIRC daemon launcher — generated by 'airc daemon install' on Windows. | ||||||
| REM Runs airc connect under bash, restarting on exit. Logs to daemon.log. | ||||||
| set AIRC_HOME=$scope_win | ||||||
| cd /d "$cwd_win" | ||||||
|
||||||
| set AIRC_BACKGROUND_OK=1 | ||||||
| :loop | ||||||
| "$bash_exe" -lc "exec '$airc_bin_win' connect" | ||||||
| echo [%date% %time%] airc connect exited. Restarting in 5s. >> "$scope_win\\daemon.err" | ||||||
| "$bash_exe" -c "exec '$airc_bin_unix' connect" | ||||||
|
Comment on lines
+5054
to
+5057
|
||||||
| echo [%date% %time%] airc connect exited. Restarting in 5s. >> daemon.err | ||||||
|
||||||
| echo [%date% %time%] airc connect exited. Restarting in 5s. >> daemon.err | |
| echo [%date% %time%] airc connect exited. Restarting in 5s. >> "%CD%\.airc\daemon.err" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment references a specific source line number (“Mirrors detect_scope() (line 135)”), which will drift as the file changes and can become misleading. Prefer describing the relationship without hard-coding a line number (or reference the function name only).