https://linen.dev logo
Deployment has not entered running state
# help
b
While deploying simple (rocket) applications work, deploying an application that uses postgres isn't working. There are no errors (just some warnings about unused crates in crate graph), everything seems to be fine but the last log-line (that is not a log, just a println) is just
Deployment has not entered the running state
. The project is
ready
.
k
Hey! Does it work locally with
cargo shuttle run
? Docker is required for local runs with db btw
b
i just tested it (not sure if i have the correct Dockerfile) and it doesn't work (i'll paste some stuff here)
Copy code
FROM rust:latest

COPY . .

RUN cargo install cargo-shuttle
RUN cargo shuttle login --api-key <key, probably not necessary>

CMD cargo shuttle run
Copy code
2022-12-04T07:42:52.109765Z ERROR cargo_shuttle::factory: got unexpected error while inspecting docker container: error trying to connect: No such file or directory (os error 2)
Error: Custom error: failed to provision shuttle_shared_db :: Postgres

Caused by:
    0: failed to provision shuttle_shared_db :: Postgres
    1: Custom error: error trying to connect: No such file or directory (os error 2)
    2: error trying to connect: No such file or directory (os error 2)
    3: No such file or directory (os error 2)
that's the docker error
k
Ah, you're running everything in docker?
b
what should be run in docker?
or what should not be run in docker?
k
You can do
cargo shuttle run
on your system, docker just needs to be installed and running and shuttle will pull down and start a postgres container
b
cargo shuttle run fails with a linking error
(i am on windows with the gnu toolchain)
Copy code
note: E:/path/to/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file \\?\path\to\dll.dll: Invalid argument
          collect2.exe: error: ld returned 1 exit status
and there is a long linking error before this
k
Hmm, this is new, I'll have to get back to you on that. So is the app you tried to deploy the same as the rocket postgres example (if not, can you share the cargo.toml and shuttle main function)? And you deploy via docker?
b
i am also unable to deploy via wsl
Copy code
toml
[lib]

[dependencies]
shuttle-service = { version = "0.7.2", features = ["web-rocket"] }
rocket = "0.5.0-rc.2"
shuttle-shared-db = { version = "0.7.2", features = ["postgres"] }
sqlx = { version = "0.6.1", features = ["runtime-tokio-native-tls", "postgres"] }
Copy code
rust
async fn rocket(#[shuttle_shared_db::Postgres] pool: PgPool) -> ShuttleRocket {
    pool.execute(include_str!("../sql/schema.sql"))
        .await
        .map_err(CustomError::new)?;
    let state = MyState(pool);
    let rocket = rocket::build()
        .manage(state)
        .mount("/", routes![win64_version, win64_upload]);

    Ok(rocket)
}
it's basically the example
k
Unable to run locally too?
b
yes
k
Can you try doing a cargo build before deploying? It has helped for some windows issues. Also can you paste the full log from deploy?
b
Copy code
warning: manifest has no description, license, license-file, documentation, homepage or repository.
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
   Packaging remote-shell-server v0.1.0 (/path/to/project/remote-shell-server)
   Archiving .cargo_vcs_info.json
   Archiving .dockerignore
   Archiving .gitignore
   Archiving Cargo.toml
   Archiving Cargo.toml.orig
   Archiving sql/schema.sql
   Archiving sql/win64_version.sql
   Archiving src/lib.rs

2022-12-04T09:56:46.782963275Z  INFO Entering queued state
Copy code
2022-12-04T09:56:46.782963275Z  INFO Entering queued state

2022-12-04T09:56:46.783524214Z  INFO Entering building state
2022-12-04T09:56:47.123265935Z  INFO     Updating crates.io index
2022-12-04T09:56:58.236766000Z  INFO warning: Patch `shuttle-aws-rds v0.7.2 (/usr/src/shuttle/resources/aws-rds)` was not used in the crate graph.
2022-12-04T09:56:58.236833651Z  INFO Patch `shuttle-persist v0.7.2 (/usr/src/shuttle/resources/persist)` was not used in the crate graph.
2022-12-04T09:56:58.242587686Z  INFO Patch `shuttle-secrets v0.7.2 (/usr/src/shuttle/resources/secrets)` was not used in the crate graph.
2022-12-04T09:56:58.248176986Z  INFO Check that the patched package version and available features are compatible
2022-12-04T09:56:58.253878468Z  INFO with the dependency requirements. If the patch has a different version from
2022-12-04T09:56:58.259779977Z  INFO what is locked in the Cargo.lock file, run `cargo update` to use the new
2022-12-04T09:56:58.265674904Z  INFO version. This may also occur with an optional dependency that is not enabled.
2022-12-04T09:57:40.353063788Z  INFO    Compiling remote-shell-server-7f7b9b87-030d-4fea-96d7-c361275e9cf6 v0.1.0 (/opt/shuttle/shuttle-builds/remote-shell-server)
2022-12-04T09:57:45.992923239Z  INFO     Finished release [optimized] target(s) in 59.14s
2022-12-04T09:57:46.107085901Z  INFO shuttle_deployer::deployment::queue: Running tests before starting up
2022-12-04T09:57:48.193372971Z  INFO     Updating crates.io index
Copy code
2022-12-04T09:57:59.159134410Z  INFO warning: Patch `shuttle-aws-rds v0.7.2 (/usr/src/shuttle/resources/aws-rds)` was not used in the crate graph.
2022-12-04T09:57:59.159213766Z  INFO Patch `shuttle-persist v0.7.2 (/usr/src/shuttle/resources/persist)` was not used in the crate graph.
2022-12-04T09:57:59.167142840Z  INFO Patch `shuttle-secrets v0.7.2 (/usr/src/shuttle/resources/secrets)` was not used in the crate graph.
2022-12-04T09:57:59.175044224Z  INFO Check that the patched package version and available features are compatible
2022-12-04T09:57:59.190873340Z  INFO with the dependency requirements. If the patch has a different version from
2022-12-04T09:57:59.203206931Z  INFO what is locked in the Cargo.lock file, run `cargo update` to use the new
2022-12-04T09:57:59.210456755Z  INFO version. This may also occur with an optional dependency that is not enabled.
2022-12-04T09:58:33.480014164Z  INFO     Finished dev [unoptimized + debuginfo] target(s) in 47.36s
2022-12-04T09:58:33.565968060Z  INFO      Running unittests src/lib.rs (opt/shuttle/shuttle-builds/remote-shell-server/target/debug/deps/remote_shell_server-da687d89fb5990b9)
2022-12-04T09:58:33.582622112Z  INFO    Doc-tests remote-shell-server

2022-12-04T09:58:33.774025146Z  INFO Entering built state
Copy code
2022-12-04T09:58:33.850313570Z  INFO Entering loading state
2022-12-04T09:58:33.862767619Z  INFO shuttle_deployer::deployment::provisioner_factory: Provisioning a shared::postgres on the shuttle servers. This can take a while...
2022-12-04T09:58:33.870893915Z DEBUG {service.ready=true} tower::buffer::worker: processing request
2022-12-04T09:58:34.520808734Z  INFO shuttle_deployer::deployment::provisioner_factory: Done provisioning database
Deployment has not entered the running state
these are the logs inside wsl
k
Ah, it looks like you have an error in your schema
{error="Run error: Custom error: error returned from database: syntax error at or near \"INT\""}
AFAIK postgres doesn't have an unsigned int type.
Not longblob either, but you could use mysql with our aws_rds resource:
The way I figured this out, btw, was to do
cargo shuttle deployment list
, and then
cargo shuttle logs <id of last deploy>
. It's my bad for not telling you to try this right away, I'll chalk it up to a sleepy sunday morning πŸ˜…
By the way, we are going to provide pre-built binaries for windows for our next release, and we'll also be refactoring how we package users projects before sending them to our build server. And we're working on improving our QA for windows. Hopefully these things will make it easier to use shuttle for windows users 🀞
b
sound great!
ok no problem, could've figured it out by myself (already used this commands lots of times)
ah ok, my bad
thansk for your help
maybe the cli should always hint to the log file
and not deploying should probably be seen as an error
but how can i use the
shuttle_shared_db
then, since it doesn't support mariadb/mysql?
ok nevermind, solved it
though i am still getting a linking error on windows when running locally
k
Nice!
We'll look into this next week, I don't think we have seen this issue before.
b
ok thanks
your project is very great and i'd like to contribute to it, so if it's possible i'd like to help you fixing this issue
k
Thanks! I'm not sure we have tested on windows with gnu toolchain yet, so I'm sure that would be very helpful πŸ™‚
b
ok great
but it does work with the mvsc toolchain (or whatever the other toolchain's name is)?
k
Yeah, that's the toolchain I've used for testing
I believe we only setup a binary release for that toolchain, but maybe we should do both
b
i think that only the minority uses gnu
i only use this one since the msvc toolchain somewhat broke and i really don't like to install visual studio build tools again
though i keep running into issues like these, so i might someday switch back πŸ˜…
ok, i got it to run locally via mariadb
thannks for your help again
k
No problem!
b
where can i say some minor issues without directly creating an issue on GH?
k
Here is fine, but feel free to open github issues as well
b
ok
1) is there a way to show what the compiling step does (sometimes it takes a very long time, maybe due to locks?)
(current forgot the others, but i'll add them here)
ah, number 2)
rocket::server: Rocket is executing inside of a custom runtime.
is this done purposely like this?
k
1. I know we had a long delay on first deploys due to fetching the crates.io index, but we now include it in our container image. I'm not a 100% sure if that change is live though, @stocky-kangaroo-53672 should be able to fill us in tomorrow 2. I think rocket outputs this message when it's not launched in the standard way with the
#[launch]
macro, either way it's running in a normal tokio runtime so it shouldn't matter.
b
2. yes, but the rocket runtime is basically just a wrapper with
rocket::async_main(async move {})
. Not sure what this does, but with this around the "main" function no more warning is emitted. could this be added for rocket or is there a loss of control over the whole runtime and thus not applicable for shuttle?
s
1. Yip, it's live. But I think our latest images are a bit old, so the index is old too
b
so i just have to update shuttle via
cargo install cargo-shuttle
(and somehow force a rebuild)?
k
From rocket's source [1] it looks like this warning is only emitted for debug builds (our deployments build in release profile), and only if the name of the tokio worker threads are not "rocket-worker" aka not started with the
#[launch]
macro (I think the point of the warning is to try to get most users to use the defaults, since it will be easier, but it should be fine not to use it). We do set some fields on the config, but only fields necessary to run your server on our end [2]. You can also set config fields yourselves in your shuttle main function if you need to. [1]: [2]:
Remaking your project container with
cargo shuttle project rm
followed by
cargo shuttle project new
should be sufficient
b
ah ok
thanks, i’ll try it out
ok i know understand what you mean by container
but does this also affect local builds?
s
Oh, I was referring to the build seeming to be stuck (1). Not the rocket warning (2)
b
yes i know
but is this for local builds? cargo project new was quite fast (iirc) so does is this only for deployments?
s
Nope, local builds are the same as running
cargo build
so their outputs should be the same with the same timings
b
hmmm
i’ll measure the build times
but a rocket + sqlx project usually compiles for 5-10 minutes
s
🀯 for a local build I would expect something less than 20 seconds
Are you building using WSL perhaps?
b
yes πŸ˜…
i can’t build locally since i am using the gnu toolchain for windows
⬆️
basically a linker errorr
s
Ahhh, I see. Does your WSL use the network driver thingy to mount the path inside WSL?
b
what network driver?
but my project is in
/mnt/
should i copy it to
~
?
s
I've seen the WSL network mount approach cause very slow file accesses (and hence builds) with C# code in the past
I think it is worth trying to see the effect
b
ok, i’ll give it a try
also, are there any fixes for gnu?
s
I ran into this about 2 years ago, so I'm not all that clear on the details. I just remember that WSL would access the windows filesystem by mounting it as a network filesystem or something along these lines
Not yet that I'm aware of
b
ok, but what is the problem? just a differrent linker than mvsc?
ah ok
s
Honestly, I have no idea yet. I'm on Linux and @kind-area-3810 is the only dev with a Windows machine. But he also codes on Linux. So we'll have to take some time to start up a windows machine and see what the issue is
b
ok
ok, now it's compiled in less than 1 second
lol