Skip to content

Commit 2d5154a

Browse files
justin808claude
andcommitted
fix: auto-clean stale overmind sockets on startup
Added automatic cleanup of stale overmind socket files when starting bin/dev. This prevents "overmind is already running" errors by safely removing socket files only when no overmind processes are actually running. The cleanup runs automatically before starting any dev mode, making the development experience more seamless. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 5f9c33c commit 2d5154a

File tree

1 file changed

+20
-0
lines changed
  • lib/generators/react_on_rails/bin

1 file changed

+20
-0
lines changed

lib/generators/react_on_rails/bin/dev

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,27 @@ def ensure_procfile(procfile)
2929
exit 1
3030
end
3131

32+
def cleanup_stale_sockets
33+
# Check for stale overmind socket files
34+
socket_files = [".overmind.sock", "tmp/sockets/overmind.sock"]
35+
36+
# Only clean up if overmind is not actually running
37+
overmind_pids = `pgrep -f "overmind" 2>/dev/null`.split("\n").map(&:to_i)
38+
39+
if overmind_pids.empty?
40+
socket_files.each do |socket_file|
41+
if File.exist?(socket_file)
42+
puts " 🧹 Cleaning up stale socket: #{socket_file}"
43+
File.delete(socket_file) rescue nil
44+
end
45+
end
46+
end
47+
end
48+
3249
def run_with_process_manager(procfile)
50+
# Clean up stale sockets before starting
51+
cleanup_stale_sockets
52+
3353
if installed?("overmind")
3454
system "overmind start -f #{procfile}"
3555
elsif installed?("foreman")

0 commit comments

Comments
 (0)