Here’s a solution that gives you error messages if ANY of your Foreman services crash on launch (in my case, web, js, css, and redis— but your Procfile.dev will have services based on your app).
And it beeps! And tells you what’s wrong by the NUMBER of beeps! 4 beeps if Rails fails to start, 3 beeps for SASS error, 2 beeps for JS build error, and 1 beep if Redis fails to start.
web: unset PORT && bin/rails server || echo '----------> RAILS FAILED TO START' && echo -ne '\007\007\007\007' js: yarn build --watch || echo '----------> ESBUILD BUILD (yarn build:js) EXITED WITH ERROR' && rm ./app/assets/builds/application.js && rm ./app/assets/builds/application.js.map && echo -ne '\007\007' css: yarn build:css --watch || echo '----------> SASS COMPILE (yarn build:css) EXITED WITH ERROR' && rm ./app/assets/builds/application.css && rm ./app/assets/builds/application.css.map && echo -ne '\007\007\007' redis: redis-server || (echo '----------> REDIS FAILED TO START' && echo -ne '\007')
My favorite thing about this solution is that it alleviates one of Foreman’s WORST problems— information overload! I know it’s funky but having those 10 dashes and an arrow literally pointing to the exact spot in your Foreman output where the sub-service crashed is super helpful!