I need two web-servers with different mount points, routes and settings at all (different port, Connection: keep-alive for one and close for another, and so on). How can I do that?
I think of something like:
tokio)Rocket is not asynchronous, so you wouldn't use epoll or tokio with Rocket. Rocket also doesn't allow you to change low-level settings such as whether it sends Connection: close or Connection: keep-alive, though it probably should.
To create to Rocket instances with different configurations, you simply need to spawn one of them in a different thread; multiplexing happens automatically. Here's an example:
use std::thread;
use rocket::config::{Config, Environment};
let config_one = Config::build(Environment::Staging)
.port(9234)
.finalize()?;
let config_two = Config::build(Environment::Production)
.port(8716)
.finalize()?;
// first instance
thread::spawn(move || {
rocket::custom(config_one, false)
.mount("/one", routes![a, b, c])
.launch();
});
// second instance
rocket::custom(config_two, false)
.mount("/two", routes![e, f, g])
.launch();
Hopefully this has been answered. Please comment if it has not and we'll reopen.
Most helpful comment
Rocket is not asynchronous, so you wouldn't use
epollortokiowith Rocket. Rocket also doesn't allow you to change low-level settings such as whether it sendsConnection: closeorConnection: keep-alive, though it probably should.To create to Rocket instances with different configurations, you simply need to spawn one of them in a different thread; multiplexing happens automatically. Here's an example: