no logs are shown
# help
b
Copy code
rust
#[shuttle_runtime::main]
async fn init() -> Result<Runner, shuttle_service::error::Error> {
    error!("test");
    Ok(Runner)
}
the command
cargo shuttle logs --latest
does not show any error but says that everything completed successfully. how to view the logs? i can't start a tracing subscriber because one is already install (i guess?) ... works fine on local builds. also, everything inside the
bind
function of runner doesn't get executed (i guess) while it does on local runs.
e
Interesting... not sure what's going on exactly but I have noticed a bit of inconsistency in logging myself as well 🤔 some regions of my code log consistently, others seem to be entirely unable to, but it's all working, I'm just not always getting logs from everywhere I'm trying to log
b
do you know a workaround?
e
not atm, no. 😔
a
maybe it might've panicked after it starts running? that's typically what tends to happen for me
e
possibly
at least in my case it's running fine but certain log lines just never show even though I know for sure that it is still running and working just fine, and the code paths they're in are definitely being run
b
i don't see any panic message
a
ah no sorry, I meant that it might've panicked then stopped logging after the fact
although I guess not if everything works
maybe if everything "completed successfully" you need to await something?
b
hmmm, at least there are no "you have to await futures" errors
s
What does
cargo shuttle deployment list
show?
b
637c5ebf-a3c0-49d4-aa2b-3a197526498a
is the last log id and all deployments completed successfully
(
completed
)
or what specific information do you need?
e
Is this a custom service you're trying to run? I think I remember seeing something similar the other week here...
b
yes
e
hmm. Not sure if it's relevant, but this is what I was recalling I think: https://discord.com/channels/803236282088161321/953005742842069013/1095034884118036500
If your bind function is returning it might explain what you're seeing
b
hmm, wdym? do i have to make sure that it only returns after i am done? this should actually be the case (gotta check it again though)...
a
There is a chance it's just not running the build script which means nothing happens or it can't find anything, meaning it just exits out and completes
b
but even the logging in the first line of the bind function doesn't show anything
and pretty sure that the build script executed
actually, not even the first line of init shows the logs (see the start of this forum thread)
that's the log(s):
Copy code
js
2023-05-02T18:13:48.622191404Z  INFO     Finished release [optimized] target(s) in 48.83s

2023-05-02T18:13:48.638522773Z  INFO Entering built state

2023-05-02T18:13:48.638719576Z  INFO Entering loading state
2023-05-02T18:13:48.642999378Z TRACE shuttle_deployer::runtime_manager: making new client
2023-05-02T18:13:48.647627424Z DEBUG shuttle_deployer::runtime_manager: Starting alpha runtime at: /opt/shuttle/shuttle-executables/d74c6f91-801e-4d7f-aef5-9adf27c30656
2023-05-02T18:13:50.651486547Z  INFO shuttle_proto::runtime: connecting runtime client
2023-05-02T18:13:50.651566085Z DEBUG hyper::client::connect::http: connecting to 127.0.0.1:19017
2023-05-02T18:13:50.654014389Z DEBUG hyper::client::connect::http: connected to 127.0.0.1:19017
2023-05-02T18:13:50.656603753Z DEBUG {service.ready=true} tower::buffer::worker: processing request
2023-05-02T18:13:50.659392746Z  INFO shuttle_deployer::deployment::run: loading project from: /opt/shuttle/shuttle-executables/d74c6f91-801e-4d7f-aef5-9adf27c30656
2023-05-02T18:13:50.661255403Z DEBUG shuttle_deployer::deployment::run: loading service
2023-05-02T18:13:50.663596475Z DEBUG {service.ready=true} tower::buffer::worker: processing request
2023-05-02T18:13:50.675638107Z  INFO {success="true"} shuttle_deployer::deployment::run: loading response
No resources are linked to this service

Service Name:  hcaptcha-solver-test
Deployment ID: d74c6f91-801e-4d7f-aef5-9adf27c30656
Status:        running
Last Updated:  2023-05-02T16:13:50Z
URI:           https://hcaptcha-solver-test.shuttleapp.rs
(javascript coloring, because why not)
actually, what does
No resourcse are linked to this service
mean?
e
just means Shuttle hasn't detected any secrets, db connections, etc., that the service should need
b
ah ok
any clue why it isn't wokring 😅 ?
e
can you share the code for your bind function?
b
Copy code
rust
struct Runner;
#[shuttle_runtime::async_trait]
impl Service for Runner {
    async fn bind(mut self, addr: SocketAddr) -> Result<(), shuttle_service::error::Error> {
        _init(addr).await.context("running ?")?;

        Ok(())
    }
}

#[shuttle_runtime::main]
async fn init() -> Result<Runner, shuttle_service::error::Error> {
    error!("test");
    Ok(Runner)
}
with the init function; nothing logs, no unwraps/expects used in the code (so hopefully no panics or so)
e
I'm not an expert here ( @gentle-ice-1561 may be able to offer some additional insight as to how this all works, perhaps? otherwise likely Shuttle folks would know for sure ) but looking at the custom service example here: https://docs.shuttle.rs/examples/custom-service Essentially it looks like the goal of
bind()
is to simply never return; you call whatever method on the things you're using or custom code that does the central logic and never returns. For discord bots that's listening to whatever discord sends their way on a more or less infinite loop, servers are generally bound to an incoming port and listen for connections, etc. So if
_init(addr)
returns, like, ever, (since nothing else in
bind()
will prevent it from finishing) then the service would stop and gracefully shut down, I think?
a
Pretty much. If the service doesn't indefinitely maintain itself (ie, something like an axum server bind) it'll just drop
g
sounds right
I do agree that loggings in the very early stages of your app (main or early in bind) seem to not show up. My knowledge of the shuttle runtime etc is not good enough to debug this yet
a
Tbh it took me so much time of just random trial and error early on to figure everything out 😂 the skill ceiling is in space rn
b
Ok thanks, I think I'll just wrap this in a webserver for better debugging for now 😅 thx for the help
e
np, good luck!
b
thanks 😅