trillium-rs / trillium

Trillium is a composable toolkit for building internet applications with async rust

Home Page:https://trillium.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

document systemfd/listenfd support

prabirshrestha opened this issue · comments

It will be good if there are examples on https://github.com/mitsuhiko/systemfd and https://docs.rs/listenfd/0.3.3/listenfd/ or a first class create/optional feature on this.

This behavior exists, and has been tested with https://crates.io/crates/catflap, but the documentation is insufficient. https://docs.trillium.rs/trillium_server_common/trait.configext#tymethod.build_listener — if a LISTEN_FD env var is available, trillium will use it on cfg(unix) systems

Although I have nothing against windows, I have no way to test windows locally and so stuff like this and signals support (graceful shutdown) are cfg(unix) only for now

That is great and example or docs would be great. I have always found it a struggle to find good examples in rust that deals with cargo watch that uses both webpack/react-create-app with rust as server.

I found this to work the best for now in package.json

{
    "scripts": {
        "preinstall": "yarn --cwd client install",
        "build": "yarn client:build && yarn server:build",
        "start": "cross-env BROWSER=none concurrently \"yarn client:start\" \"yarn server:start\"",
        "client:start": "yarn --cwd client start",
        "client:build": "yarn --cwd client build",
        "client:test": "yarn --cwd client test",
        "server:start": "cargo watch -x 'run serve'",
        "server:build": "cargo build --release"
    },
    "devDependencies": {
        "concurrently": "^6.1.0",
        "cross-env": "^7.0.3"
    }
}

with proxy it would simplify here.

trillium_smol::run(
    Router::new()
        .get("/api", api)
        .get("*", Proxy::new("http://localhost:3000"))
);

Or some sort of webpack-dev-server handler.

I'm ok with just unix for now since that is what I use rust mainly on.

I'll add this to the guide, although the LISTEN_FD support should not end up being very important because the soon-to-be-released trillium cli includes a hot-reloading dev server.

I think a webpack dev server would be amazing, and looked into using https://github.com/swc-project/swc for this, but haven't been able to get it working yet