refined-receptionist-71124
05/28/2023, 11:06 AMrs
#[shuttle_runtime::main]
async fn rocket(
#[shuttle_aws_rds::Postgres()]
pool: PgPool,
) -> shuttle_rocket::ShuttleRocket {
pool.execute(include_str!("../schema.sql"))
.await
.map_err(CustomError::new)?;
let state = MyState { pool: pool };
let rocket = rocket::build()
.mount("/v1.0", routes![outages, _area_search])
.mount("/esp/2.0", routes![esp_index, esp_status])
.manage(state);
Ok(rocket.into())
}
I have docker and postgresql installed, but I haven't set anything up besides starting a postgres server. The docs aren't super clear about if any setup is needed?
When I try to run locally with cargo shuttle run
, I get:
Finished dev [unoptimized + debuginfo] target(s) in 4.51s
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: tonic::transport::Error(Transport, hyper::Error(Listen, Os { code: 48, kind: AddrInUse, message: "Address already in use" }))', /Users/brk/.cargo/registry/src/github.com-1ecc6299db9ec823/shuttle-runtime-0.17.0/src/alpha/mod.rs:87:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: status: Internal, message: "failed to connect to provisioner", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Sun, 28 May 2023 10:57:47 GMT", "content-length": "0"} }
Which looks like it's either not provisioning a DB (but the whole idea is that this should be automatic, right?) or the address it's trying to use is in use (But I'm not sure what by?).
Could someone point me in the right direction?refined-receptionist-71124
05/28/2023, 11:09 AMrustc 1.69.0 (84c898d65 2023-04-16)
, Cargo.toml:
[package]
name = "eskom-calendar-api"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
chrono = "0.4.19"
csv = "1.1"
reqwest = { version = "0.11", features = ["json"] }
rocket = { version = "0.5.0-rc.3", features = ["json"] }
shuttle-rocket = { version = "0.17.0" }
shuttle-runtime = { version = "0.17.0" }
shuttle-shared-db = { version = "0.17.0", features = ["postgres"] }
shuttle-aws-rds = { version = "0.17.0", features = ["postgres"] }
sqlx = { version = "0.6.3", features = ["runtime-tokio-native-tls", "postgres"] }
tokio = { version = "1.28.0", features = ["full"] }
sparse-lamp-74430
05/28/2023, 11:12 AMrefined-receptionist-71124
05/28/2023, 11:16 AMrefined-receptionist-71124
05/28/2023, 11:18 AMthread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: tonic::transport::Error(Transport, hyper::Error(Listen, Os { code: 48, kind: AddrInUse, message: "Address already in use" }))', /Users/brk/.cargo/registry/src/github.com-1ecc6299db9ec823/shuttle-runtime-0.17.0/src/alpha/mod.rs:87:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: status: Internal, message: "failed to connect to provisioner", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Sun, 28 May 2023 11:15:21 GMT", "content-length": "0"} }
So I guess you're right, it must be something with my systemsparse-lamp-74430
05/28/2023, 11:19 AMsparse-lamp-74430
05/28/2023, 11:21 AMrefined-receptionist-71124
05/28/2023, 11:23 AM$ docker --version
Docker version 24.0.2, build cb74dfcd85
I'm not sure why my user wouldn't be able to access it by default? (or how to give it permission if it isn't able to access it)
I'm going to try shut down postgres and reinstall, which will hopefully get rid of the addrInUse
refined-receptionist-71124
05/28/2023, 11:30 AMthread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: tonic::transport::Error(Transport, hyper::Error(Listen, Os { code: 48, kind: AddrInUse, message: "Address already in use" }))', /Users/brk/.cargo/registry/src/github.com-1ecc6299db9ec823/shuttle-runtime-0.17.0/src/alpha/mod.rs:87:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: status: Internal, message: "failed to connect to provisioner", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Sun, 28 May 2023 11:28:14 GMT", "content-length": "0"} }
gentle-ice-1561
05/28/2023, 11:36 AMgentle-ice-1561
05/28/2023, 11:36 AMrefined-receptionist-71124
05/28/2023, 1:07 PM87 │ println!("{}", addr);
88 │ router.serve(addr).await.unwrap();
89 │ }
And it looks like the address is 127.0.0.1:7999
. When I look at the process using port 7999 via lsof
and
$ lsof -nP -iTCP:7999
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
eskom-cal 19156 brk 9u IPv4 0xbb0761ebe9a30759 0t0 TCP 127.0.0.1:7999 (LISTEN)
$ ps 19156
PID TT STAT TIME COMMAND
19156 ?? S 0:00.21 /Users/brk/projects/eskom-calendar-api/target/debug/eskom-calendar-api --port 7999 --provisioner-address http://localhost:15532 --storage-manager-type working-dir --storage-manager-path /Users/brk/projects/eskom-calendar-api
(eskom-calendar-api is the name of the project)
So it seems like I did something while setting up shuttle which caused this issue. I'm going to kill the related processes and see if that helpsrefined-receptionist-71124
05/28/2023, 1:37 PMkill -9 19156
and then cargo shuttle run
caused everything to run smoothly. So that's good.
I've confirmed that this behaviour is easy to reproduce by starting shuttle cargo shuttle run
, sending it to the background ^Z
, and then attempting to start shuttle in a different process cargo shuttle run
. Then the second shuttle instance will emit the same error as I was getting.
I've opened a PR (https://github.com/shuttle-hq/shuttle/pull/950) to clarify the error message (basically just printing out the address which could not be found).refined-receptionist-71124
05/28/2023, 1:42 PMcargo shuttle run
after ensuring that port 7999 is clear, I get this error:
2023-05-28T13:32:29.942039Z ERROR cargo_shuttle::provisioner_server: got unexpected error while inspecting docker container: error trying to connect: No such file or directory (os error 2)
2023-05-28T13:32:29.943945Z ERROR cargo_shuttle: failed to load your service error="Custom error: failed to provision shuttle_aws_rds :: Postgres"
Which is fine, I think I just need to setup a docker. But, if I now try to run cargo shuttle run
again, I get the original error complaining about ports not being open:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: tonic::transport::Error(Transport, hyper::Error(Listen, Os { code: 48, kind: AddrInUse, message: "Address already in use" }))', /Users/brk/.cargo/registry/src/github.com-1ecc6299db9ec823/shuttle-runtime-0.17.0/src/alpha/mod.rs:87:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: status: Internal, message: "failed to connect to provisioner", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Sun, 28 May 2023 13:42:10 GMT", "content-length": "0"} }
So I think that shuttle is not cleaning up its ports, or its leaving something running in the background. This seems like a bug?gentle-ice-1561
05/28/2023, 2:11 PMrefined-receptionist-71124
05/28/2023, 2:21 PMrefined-receptionist-71124
05/28/2023, 2:23 PMgot unexpected error while inspecting docker container: error trying to connect: No such file or directory (os error 2)
errorrefined-receptionist-71124
05/28/2023, 2:29 PMbrew install docker
doesn't install the docker I needed. brew install homebrew/cask/docker
was the correct command, and then I needed to open the app to get the docker engine started.
Is there a documentation repository I could contribute to? The content on https://docs.shuttle.rs/resources/shuttle-aws-rds is great but I'd love to have a troubleshooting section.agreeable-painting-48846
05/28/2023, 9:12 PM