mc-router icon indicating copy to clipboard operation
mc-router copied to clipboard

Any way to add mapping to current instance to prevent un-graceful rebooting?

Open Jafner opened this issue 4 years ago • 6 comments

I run multiple servers for a small group of 10-20 friends. A couple users like to hop across modpacks. I am frequently asked to spin up a new server (a very quick task, usually), but adding the new container to the mc-router via updating the mapping command in docker-compose.yml, then running docker-compose up -d (expectedly) causes all users connected to any server behind the proxy to be disconnected.

Is there any way to add a mapping to a running mc-router container without shutting it down and restarting it?

Jafner avatar Aug 10 '21 06:08 Jafner

Until https://github.com/itzg/mc-router/issues/17 you will need to use the REST API or switch to Kubernetes service discovery.

itzg avatar Aug 10 '21 18:08 itzg

Awesome, thanks for the clarification.

Jafner avatar Aug 10 '21 18:08 Jafner

Can you give an example of how to interact with the REST API for users who may have never interacted with one before?

Is setting an API binding in the docker-compose file required, or does the container have internal tools capable of calling the API with docker exec?

Jafner avatar Aug 10 '21 18:08 Jafner

With a command: of --mapping=e6.example.com=e6-056:25565,vanilla.example.com=vanilla:25565,tnp.example.com=tnp:25565 --api-binding=0.0.0.0:25566, I run curl <container-ip>:25566/routes from the host and get: 404 page not found

I do not have port 25566 mapped from the host to the container in the docker-compose file, should I?

Jafner avatar Aug 10 '21 18:08 Jafner

Since you addressed the curl operation with the container IP the mapping of the port isn't needed. As for the usage, I rediscovered that examples will be very helpful, since the GET operations need the Accept header, such as:

curl -H Accept:application/json localhost:25564/routes

and the POST operations need -H Content-Type:application/json.

itzg avatar Aug 10 '21 21:08 itzg

Awesome! In my case, curl -H Accept:application/json 172.25.0.2:25566/routes worked great!

Jafner avatar Aug 10 '21 22:08 Jafner