This example will explain how to create a custom Shuttle service using Poise and Axum.
Service
for a custom service that serves a Discord bot alongside a web server created using Axum.
Secrets.toml
(explained below). It’s very important that you don’t reveal your token to anyone, as it can be abused. Create a .gitignore
file to omit your Secrets.toml
from version control.Secrets.toml
file needs to be in the root of your directory once the project has been initialised - the file will use a format similar to a .env
file, like so:
bot
scope.shuttle-runtime
.
We also want to add several dependencies for this - make sure your Cargo.toml looks like below:
shuttle_runtime::main
.
shuttle_service::Service
for our wrapper. If you need to bind to an address,
for example if you’re implementing service for an HTTP server, you can use the addr
argument from bind
.
You can only have one HTTP service bound to the addr
, but you can start other services that don’t rely on
binding to a socket, like so:
shuttle_runtime::main
function and add implementation
for setting up each of our services for the struct, like so:
run
command: