官方文档:https://rocket.rs/v0.5/guide 包文档:https://api.rocket.rs/v0.5/rocket/
代码下载地址
https://github.com/rwf2/Rocket/releases
启动服务
例如下载的代码版本:Rocket-0.5.0.tar.gz
tar xzf Rocket-0.5.0.tar.gz
cd Rocket-0.5.0/examples/hello
ROCKET_PORT=80 ROCKET_ADDRESS=0.0.0.0 cargo run
配置方式:环境变量 or 配置文件
环境变量
通过环境变量指定服务监听的网口和端口。
Rocket 服务的配置可以参考连接:https://rocket.rs/v0.5/guide/configuration/
Rocket reads all environment variable names prefixed with ROCKET_ using the string after the _ as the name of a configuration value as the value of the parameter as the value itself. Environment variables take precedence over values in Rocket.toml. Values are parsed as loose form of TOML syntax.
配置文件
配置文件:Rocket.toml
例如一个典型的配置如下:
[default]
address = "127.0.0.1"
port = 8000
workers = 16
max_blocking = 512
keep_alive = 5
ident = "Rocket"
ip_header = "X-Real-IP" # set to `false` to disable
log_level = "normal"
temp_dir = "/tmp"
cli_colors = true
secret_key = "hPrYyЭRiMyµ5sBB1π+CMæ1køFsåqKvBiQJxBVHQk="
[default.limits]
form = "64 kB"
json = "1 MiB"
msgpack = "2 MiB"
"file/jpg" = "5 MiB"
[default.tls]
certs = "path/to/cert-chain.pem"
key = "path/to/key.pem"
[default.shutdown]
ctrlc = true
signals = ["term", "hup"]
grace = 5
mercy = 5