Skip to content

Commit

Permalink
Custom shuttle binary filename (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaro00 authored Oct 19, 2023
1 parent f5efab4 commit fb5e157
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion other/standalone-binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 4 additions & 5 deletions other/standalone-binary/README.md
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
File renamed without changes.

0 comments on commit fb5e157

Please sign in to comment.