on main help sign in
fix(server): log earlier so socket cleanup is always recorded

Sets up the persistent log file before the client checks the socket, so any message about detecting or clearing a leftover socket is saved to disk instead of being lost. Co-Authored-By: Charm Crush <crush@charm.land>

commit62baa95ef843e086c8bac6bf2659b7252a8b07b2 authorChristian Rocha <christian@rocha.is> dateMon 8 Jun 2026, 09:24 (4 months ago) parenta442f26
1 file changed+8
internal/cmd/root.go+8
internal/cmd/root.go+8
@@ -416,6 +416,14 @@ func connectToServer(cmd *cobra.Command) (*client.Client, *proto.Workspace, func
416416// version matches the client; on mismatch it shuts down the old server
417417// and starts a fresh one.
418418func ensureServer(cmd *cobra.Command, hostURL *url.URL) error {
419+ // Initialize the persistent log here so stale-socket diagnostics
420+ // emitted before connectToServer runs are captured in the per-host
421+ // server log file. crushlog.Setup uses sync.Once internally, so the
422+ // later call from connectToServer becomes a no-op.
423+ debug, _ := cmd.Flags().GetBool("debug")
424+ logFile := filepath.Join(config.GlobalCacheDir(), "server-"+safeHostName(hostURL), "crush.log")
425+ crushlog.Setup(logFile, debug)
426+
419427 switch hostURL.Scheme {
420428 case "unix", "npipe":
421429 needsStart := false