From cbc1ca7f70db18c4fb90aa1e13be564be603609a Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Thu, 16 Nov 2023 11:58:36 +0100 Subject: [PATCH 1/2] Default to port 3000 while allowing override With this configuration `bin/dev` will use port 3000, but `bin/dev -p 3001` will correctly start the server on port 3001. --- lib/install/Procfile.dev | 2 +- lib/install/dev | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/install/Procfile.dev b/lib/install/Procfile.dev index 59915d5..cce5ded 100644 --- a/lib/install/Procfile.dev +++ b/lib/install/Procfile.dev @@ -1,2 +1,2 @@ -web: env RUBY_DEBUG_OPEN=true bin/rails server -p 3000 +web: env RUBY_DEBUG_OPEN=true bin/rails server css: bin/rails tailwindcss:watch diff --git a/lib/install/dev b/lib/install/dev index 74ade16..a4e05fa 100755 --- a/lib/install/dev +++ b/lib/install/dev @@ -5,4 +5,7 @@ if ! gem list foreman -i --silent; then gem install foreman fi +# Default to port 3000 if not specified +export PORT="${PORT:-3000}" + exec foreman start -f Procfile.dev "$@" From 313f257697ff5ca3a637905f811064c8576f4276 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Thu, 16 Nov 2023 12:01:26 +0100 Subject: [PATCH 2/2] Lazily load the debugger gem Some docker environments will trigger an error related to unix sockets and permissions on temporary folders. Loading the debugger lazily mitigates the issue so at least rails can be started without crashing, while keeping the remote debugging available for other environments that support it. --- lib/install/Procfile.dev | 2 +- lib/install/dev | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/install/Procfile.dev b/lib/install/Procfile.dev index cce5ded..da151fe 100644 --- a/lib/install/Procfile.dev +++ b/lib/install/Procfile.dev @@ -1,2 +1,2 @@ -web: env RUBY_DEBUG_OPEN=true bin/rails server +web: bin/rails server css: bin/rails tailwindcss:watch diff --git a/lib/install/dev b/lib/install/dev index a4e05fa..ad72c7d 100755 --- a/lib/install/dev +++ b/lib/install/dev @@ -8,4 +8,9 @@ fi # Default to port 3000 if not specified export PORT="${PORT:-3000}" +# Let the debug gem allow remote connections, +# but avoid loading until `debugger` is called +export RUBY_DEBUG_OPEN="true" +export RUBY_DEBUG_LAZY="true" + exec foreman start -f Procfile.dev "$@"