mpyw / php-hyper-builtin-server

Reverse proxy for PHP built-in server which supports multiprocessing and TLS/SSL encryption
MIT License
106 stars 11 forks source link

Start server on the next unoccupied port #14

Closed antonkomarev closed 4 years ago

antonkomarev commented 4 years ago

This feature is very useful when you are starting multiple servers. If your port is occupied - it will try to start it on the next free port.

@mpyw what do you think?

If you don't like to have this feature enabled by default - we could add option -f to enable this feature, like:

hyper-run -s localhost:4000 -f -c ~/cert.pem -t ./public

Screenshot from 2020-06-02 03-05-08

antonkomarev commented 4 years ago

You want it to work all the time or only with -f option?

mpyw commented 4 years ago

"random" is not really random, it's like finding the next available port number from well known port numbers such as 8000 for local servers.

antonkomarev commented 4 years ago

Good idea.

I propose to use these common specification: Scheme Default Range
HTTP 8000 8000-8099
HTTPS 44300 44300-44399
hyper-run -S localhost -s localhost -c ~/cert.pem -t ./public

This command will run HTTP proxy on 8000 port and HTTPS proxy on 44300 port by default. If any of them occupied - the port number will be increased within the range.

antonkomarev commented 4 years ago

@mpyw I've finished this feature. Changed default ports in documentation and tests to 8000 and 43300. It's not a breaking change because people always were needed to start server with port.

README is more user friendly now. We are showing how to quick start server at the first place, and only then showing full command reference :wink:

antonkomarev commented 4 years ago

Released as v3.1.0