diff --git a/other/standalone-binary/Cargo.toml b/other/standalone-binary/Cargo.toml index f89abb9b..b7ca5d15 100644 --- a/other/standalone-binary/Cargo.toml +++ b/other/standalone-binary/Cargo.toml @@ -4,9 +4,13 @@ version = "0.1.0" edition = "2021" publish = false +[[bin]] +name = "multi-binary" +path = "src/bin/shuttle.rs" + [[bin]] name = "standalone" -path = "src/standalone.rs" +path = "src/bin/standalone.rs" [dependencies] axum = "0.6.18" diff --git a/other/standalone-binary/README.md b/other/standalone-binary/README.md index 8f7905c9..e8829b65 100644 --- a/other/standalone-binary/README.md +++ b/other/standalone-binary/README.md @@ -1,11 +1,10 @@ # Standalone binary - run an app with Shuttle or standalone -This example shows how to separate a project's Shuttle logic from its core functionality so that two binaries can be made: one running with Shuttle using `cargo shuttle run` that can be deployed to Shuttle, and one that can be run with `cargo run --bin ...`. +This example shows how to separate a project's Shuttle logic from its core functionality so that two binaries can be made: one for running with `cargo shuttle run` and deploying to Shuttle, and one that can be run with `cargo run --bin ...`. -The main idea is to have a main binary that Shuttle runs, and another binary that runs standalone. All startup logic is placed in the binary source files, while the implementation (endpoints etc) is moved to the library of the crate. -- `src/main.rs` is the main binary with Shuttle, run with `cargo shuttle run` -- `src/standalone.rs` is without Shuttle, run with `cargo run --bin standalone` (you can change the name) +- `src/bin/shuttle.rs` is the main binary with Shuttle, run with `cargo shuttle run`. Note that the `[[bin]]` entry in `Cargo.toml` needs to have the same name as the crate. The file can have any name you want. +- `src/bin/standalone.rs` is without Shuttle, run with `cargo run --bin standalone` (you can change the name) -This example shows how to use separate logic for getting secrets, but the same approach can be applied to other resources that are initiated by Shuttle's main function. +This example shows how to use separate logic for getting secrets (`shuttle-secrets` vs homemade solution), but the same approach can be applied to other resources that are initiated by Shuttle's main function. diff --git a/other/standalone-binary/src/main.rs b/other/standalone-binary/src/bin/shuttle.rs similarity index 100% rename from other/standalone-binary/src/main.rs rename to other/standalone-binary/src/bin/shuttle.rs diff --git a/other/standalone-binary/src/standalone.rs b/other/standalone-binary/src/bin/standalone.rs similarity index 100% rename from other/standalone-binary/src/standalone.rs rename to other/standalone-binary/src/bin/standalone.rs