jeansaad / chalet

🏩 A simple process manager for developers. Start apps from your browser and access them using local domains
MIT License
156 stars 19 forks source link

Feature Request: Reuse random port number when using `run` command #31

Open svicalifornia opened 2 years ago

svicalifornia commented 2 years ago

The chalet CLI has a run command, which sets up and runs a temporary server, outputs the server's logs to STDOUT, and removes the server config (to clean up) when the server process has stopped.

However, if I need to stop the server and restart it for some reason, then it will run under a different port number the second time (typically the next number in some sequence). If I switch to the browser tab where I had loaded the app in its first run, it will have the first port number in its URL, but that port number is no longer being used — therefore reloading that tab will fail with a server-not-found error.

It would be great if the chalet daemon would remember servers previously run and their assigned port numbers, so that if another server is run with the same name, the previously used port number could be reused. This could simply be an in-memory hash that would persist only while the chalet daemon is running. The run command would still clear the server's temporary config file when the run command exits, but just keep the port number in an entry for that server name in the daemon's memory.

svicalifornia commented 2 years ago

And no, using the -p/--port option is not a suitable workaround for this request. I specifically want chalet to assign the port numbers and ensure that each server will have a unique port number. However, I also want chalet to reuse a port number when a server is killed and restarted.