Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt at deploying on shuttle.rs #2

Closed
wants to merge 16 commits into from
Closed

Conversation

alsuren
Copy link

@alsuren alsuren commented Apr 13, 2022

This is blocked on shuttle-hq/shuttle#118 . ... nevermind. I hacked around it by implementing [Into]Service myself.

``` $ cargo shuttle deploy Error: failed to package cargo project

Caused by:
all dependencies must have a version specified when packaging.
dependency shuttle-service does not specify a version
Note: The packaged dependency will use the version from crates.io,
the git specification will be removed from the dependency declaration.


Specifying a version as well as a git url gives:

$ cargo shuttle deploy
Packaging dancelist v0.1.0 (/Users/alsuren/src/dancelist)
Archiving .cargo_vcs_info.json
Archiving .github/workflows/lint.yml
Archiving .github/workflows/rust.yml
Archiving .gitignore
Archiving AUTHORS
Archiving CONTRIBUTING.md
Archiving Cargo.lock
Updating crates.io index
note: package axum v0.4.8 added to the packaged Cargo.lock file
note: package axum-core v0.1.2 added to the packaged Cargo.lock file
note: package matchit v0.4.6 added to the packaged Cargo.lock file
note: package shuttle-codegen v0.2.5 added to the packaged Cargo.lock file, was originally sourced from https://github.com/getsynth/shuttle?branch=chore/axum-0.5#a5ebf856
note: package shuttle-service v0.2.5 added to the packaged Cargo.lock file, was originally sourced from https://github.com/getsynth/shuttle?branch=chore/axum-0.5#a5ebf856
Archiving Cargo.toml
Archiving Cargo.toml.orig
Archiving LICENSE
Archiving README.md
Archiving dancelist.example.toml
Archiving debian-scripts/dancelist.service
Archiving events_schema.json
Archiving public/stylesheets/main.css
Archiving src/config.rs
Archiving src/controllers/bands.rs
Archiving src/controllers/callers.rs
Archiving src/controllers/cities.rs
Archiving src/controllers/index.rs
Archiving src/controllers/mod.rs
Archiving src/controllers/organisations.rs
Archiving src/controllers/reload.rs
Archiving src/errors.rs
Archiving src/extractors.rs
Archiving src/icalendar.rs
Archiving src/importers/balfolknl/mod.rs
Archiving src/importers/folkbalbende/mod.rs
Archiving src/importers/folkbalbende/types/bool_as_int.rs
Archiving src/importers/folkbalbende/types/int_as_string.rs
Archiving src/importers/folkbalbende/types/mod.rs
Archiving src/importers/mod.rs
Archiving src/importers/webfeet/mod.rs
Archiving src/importers/webfeet/types.rs
Archiving src/lib.rs
Archiving src/main.rs
Archiving src/model/dancestyle.rs
Archiving src/model/event.rs
Archiving src/model/events.rs
Archiving src/model/filters.rs
Archiving src/model/mod.rs
Archiving templates/bands.html
Archiving templates/callers.html
Archiving templates/cities.html
Archiving templates/index.html
Archiving templates/organisations.html
Error: failed to deploy cargo project

Caused by:




<title>404 Not Found</title>



404: Not Found


The requested resource could not be found.






Rocket


</details>

@alsuren
Copy link
Author

alsuren commented Apr 15, 2022

After impl Service myself I get:

   Compiling reqwest v0.11.9
   Compiling dancelist v0.1.0 (/opt/unveil/crates/dancelist)
    Finished dev [unoptimized + debuginfo] target(s) in 1m 37s

        Project:            dancelist
        Deployment Id:      d3a0e264-f785-42d5-bf85-0d39aba5fb36
        Deployment Status:  ERROR: "a cdylib was not created"
        Host:               dancelist.shuttleapp.rs
        Created At:         2022-04-15 06:38:17.692974962 UTC

[edit: note that cargo-shuttle's exit code is still "success" in this case :-( ]

@alsuren
Copy link
Author

alsuren commented Apr 15, 2022

huzaah! https://dancelist.shuttleapp.rs/

@alsuren alsuren changed the title WIP: attempt at deploying on shuttle.rs (blocked on axum 0.5) WIP: attempt at deploying on shuttle.rs Apr 15, 2022
@alsuren alsuren changed the title WIP: attempt at deploying on shuttle.rs attempt at deploying on shuttle.rs Apr 15, 2022
@alsuren
Copy link
Author

alsuren commented Apr 15, 2022

I can't see a way to get at the logs of my project on production, so I'm doing all of my debugging on localhost in their docker-compose setup. My current development workflow is therefore:

set up shuttle prod:

  • cargo quickinstall cargo-shuttle (0.2.5 has a pre-built package now, so this will take < 1 second)
  • cargo shuttle login and remember your api key

setup your local shuttle in a docker:

check locally:

  • run the debug version of cargo-shuttle, and point it at your project: cargo check && \in ../shuttle cargo run -p cargo-shuttle -- deploy --working-directory=../dancelist/ --allow-dirty
    (\in is the in command from in-directory. You can get it from cargo quickinstall in-directory). bash requires the \ but zsh and powershell don't. Unfortunately, my brain is wired up to how gnu readline treats short/long words (and by a historical quirk, therefore also all GUI apps on macos), so I become irrationally angry whenever I try to use zsh's ZLE input system)
    • I wanted to add && curl localhost:8000 -H "Host: dancelist.shuttleapp.rs" -vvv, but there seems to be a race whereby cargo shuttle deploy can return before the service is actually listening :-(
    • I also found that cargo shuttle deploy can fail, and still exit successfully (see attempt at deploying on shuttle.rs #2 (comment)) so that breaks any &&/|| bash chaining that you want to do

deploy to production

  • cargo check && cargo shuttle deploy --allow-dirty
    • there's no way to get any logs out of this, as far as I can tell.

I'm mostly documenting this so that the upstream shuttle team can have an idea of what workflows their users desire, and are willing to hack into place (think "desire path"). I'm assuming that the team already plans to support this kind of workflow in a first-class manner, but there may be quick wins that they're missing. It's also worth going though and looking at the titles of the commits, to work out which steps I needed to take to unblock myself, and which things I tried without success.

get(|| async {
(
[(header::CONTENT_TYPE, "text/css")],
include_str!("../public/stylesheets/main.css"),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed this with Andrew - edit-compile-serve iteration times on axum are pretty slow, so his previous get_service(ServeDir::new(config.public_dir.join("stylesheets"))) approach is super valuable if you want to iterate quickly on your CSS.

let app = setup_app(&config).await?;

println!("Listening on {}", config.bind_address);
log::warn!("Listening on {}", config.bind_address);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get any logging out of shuttle. I don't they set anything up to consume logs before loading the .so, so all logging goes nowhere. println statements are visible in the docker logs though.

// We can't use the shuttle_service::main macro because that needs a SimpleService, and orphan rules
// do not allow us to impl anything useful for SimpleService outside of the shuttle_service crate.
struct MyService;
impl MyService {
Copy link
Author

@alsuren alsuren Apr 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that we can't use the shuttle_service::main macro (due to interactions with the orphan rule) is super-annoying. That said, it feels philosophically aligned with the "batteries included" approach that shuttle has first-party support for all of the things, so they can handle automatic injection of logging and databases etc, and things "just work".

I was about to suggest documenting the "impl Service" workaround with an example, but maybe that's not the answer. Maybe it would be better to allow users to supply their own version of shuttle-service as a git dependency or something? I don't know.

Relatedly, Andrew suggests that maybe breaking with the .crate packaging format would be beneficial - some companies might not be comfortable with pushing their source code elsewhere? (the kind of company that prefers to run their own jenkins instances might not be the target market for shuttle though). If shuttle could ship a docker-compose based setup for building the .so file, then we might be able to sidestep the "no git dependencies" issue? I heard a rumour that synced volumes via virtiofs are pretty fast these days? I've not tried it myself though. Also, it's hard to beat the "just send it to us and we'll build it on our infini-core beast of a server that also has a cache of all of your crate's deps already" approach [edit: unless you're already committed to compiling locally for local dev?].

@codecov-commenter
Copy link

Codecov Report

Merging #2 (dad4d05) into main (8c027b8) will increase coverage by 14.48%.
The diff coverage is 71.84%.

@@            Coverage Diff            @@
##           main       #2       +/-   ##
=========================================
+ Coverage      0   14.48%   +14.48%     
=========================================
  Files         0       24       +24     
  Lines         0     5406     +5406     
=========================================
+ Hits          0      783      +783     
- Misses        0     4623     +4623     
Impacted Files Coverage Δ
src/errors.rs 0.00% <ø> (ø)
src/main.rs 4.00% <ø> (ø)
src/config.rs 63.88% <25.00%> (ø)
src/lib.rs 11.13% <72.77%> (ø)
src/controllers/callers.rs 0.00% <0.00%> (ø)
src/model/event.rs 20.53% <0.00%> (ø)
src/controllers/bands.rs 0.00% <0.00%> (ø)
src/icalendar.rs 0.00% <0.00%> (ø)
src/model/dancestyle.rs 2.94% <0.00%> (ø)
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c027b8...dad4d05. Read the comment docs.

@alsuren
Copy link
Author

alsuren commented Feb 4, 2024

Just closing some old PRs. Nothing to see here.

@alsuren alsuren closed this Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants