-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
30 lines (26 loc) · 831 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use shuttle_runtime::tokio::time;
use shuttle_runtime::SecretStore;
use std::process::Command;
// start a service to run the shuttle_run.sh bash script
#[shuttle_runtime::main]
#[allow(unused_must_use)]
async fn shuttle_main(
#[shuttle_runtime::Secrets] secrets: SecretStore,
) -> Result<MyService, shuttle_runtime::Error> {
// run the project
Command::new("bash")
.arg("/app/shuttle_run.sh")
.envs(secrets.clone().into_iter())
.spawn()
.expect("Failed to start project")
.wait();
Ok(MyService {})
}
struct MyService {}
#[shuttle_runtime::async_trait]
impl shuttle_runtime::Service for MyService {
async fn bind(self, _addr: std::net::SocketAddr) -> Result<(), shuttle_runtime::Error> {
time::sleep(time::Duration::from_secs(1)).await;
Ok(())
}
}