question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto-assign a port

See original GitHub issue

To properly test the project I’m working on, I need two separate apps running at the same time. I’ve got similar rollup configs for each.

Both are using firebase serve for their static assets. It has the handy feature of finding its own port if the default one is taken:

[1] ⚠  hosting: Port 5000 is not available. Trying another port...
[1] i  hosting: Serving hosting files from: packages/ui/site
[1] ✔  hosting: Local server: http://0.0.0.0:5005

Would you be amenable to a PR that added this feature to rollup-plugin-livereload?

This passage from the upstream changelog leads me to believe that the plugin is the correct place to fix this:

You can now use server.on ‘error’ in your code to catch the “port in use” message gracefully. The CLI now handles this nicely as well.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
thghcommented, Aug 1, 2019

If this doesn’t add much dependencies, then yes! Could you build the feature with https://github.com/Rich-Harris/port-authority ?

If you just want to solve your problem => assign a random port once per project For example: livereload({ port: 51823 }).

0reactions
thghcommented, Aug 27, 2020

Checkout out rollup-plugin-livereload@2.0.0 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Example script to auto assign port using webpack-dev-server
Example script to auto assign port using webpack-dev-server - webpack-port-auto-assign.js.
Read more >
C automatically assign port - Stack Overflow
I just wanted to know how to use C to automatically assign a free port (and see what was used) if a specific...
Read more >
Automatic port assignment - Continuous Delivery with Docker ...
Automatic port assignment Let's try to run the second Tomcat container without stopping the first one: $ docker run -d -p 8080:8080 ...
Read more >
Auto-Assign Port VLAN based on Connected Device (e.g. ...
I have some N3024P switches that need to be set up. There is a requirement to automatically place VOIP phones that are connected...
Read more >
To change the port a CMS uses for accepting requests
Under Common Settings, deselect the Auto assign check box for Request Port, then type the port number you want the server to listen...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found