Clean host file when shut down - recreate whie start-process

Hi Local by Flywheel,
your App is great!
Perfect easy-daily-life for Dev’s. Maybe one small change would make life of Developer even simpler and the app even more helpful.

  • clean up the hosts file by stop-site/shut-down app
  • rewrite an/all entry in hosts file during start-site/start-app process

I found a work-around but would be great for less error-prone if «Local by Flywheel» would integrate this by default:

Daily-Work: without search-and-replace
I use the live URL also in «local by flywheel» e.G. «doitright.com» instead «doitright.local». This helps a lot and reduce the work and error-prone during publishing: No search-and-replace for all url’s!

This works fine. Only if I will check the live Site it’s a problem.

Problem
Because «Local by Flywheel» 3.0.4 create a entry in hosts-file on OS 10.14.3 (192.168.95.100 www.doitright.com #Local Site) only once during the project-creation-process.

After this creation-process, if I type www.doitright.com in a local browser, the request will responded from the «local by flywheel docker-server». Also if I shut-down the App.

Workaround
So I have to change the hosts file manually.

Feature Request
This work-arround is ok, but it would be less error-prone if «Local by Flywheel» would clean-up the hosts file when shut-down and re-create it during the start-process.

Advantage
This would make it easy to do dev-stuff local and check stuff on live-server only by start or stop a site in «local by Flywheel».
Also the cryptical «not found» page would not longer shown, if the App is not running but the hosts file point to the Local-by-Flywheel-Docker-Server.

Feature Request: in detail
Would be great if the app would change the entries in the hosts file depending on the status of each «Local Sites»:
START SITE => Running -> entry is written.
STOP SITE => Stopped -> entry is deleted.

STOP APP => all entries deleted.

Kind Regards
Martin

Hey Martin,
Interesting idea! We typically recommend using a different URL for local development to make it explicitly clear which version of your site (local or production) you’re editing. With the setup you mentioned above, how do you discern between the local and production environments. Maybe I’m missing something?

Hi flyjack,
Thanks for reply.

I created a function to discern between the local and production:54

I include the shortcode in the template/sites.
Because on remote-server, the root-folder is not «/app»: I get an «is_local» on each website…