It is a simple server listening on a port and returning a string. What sort of project would I create that will start the app? And can I just copy the executable into the folder?
There is apparently a game server called a Rust Server but this app isn’t that. Just a simple server app written in Rust.
So we don’t fully support Rust, in that our containers are not up to date with the latest version (we’re working on this!), but here’s an old app that can point you in the right direction on how to get started: Rust Web Server
Appreciate it. It pulled the code from the github repo but it didn’t try to build or there should have been an output directory. The static index page appears but the server is surely not running.
It could be the way the repo is set up with two projects and a library but I don’t know how the .toml files work so I can’t really edit anything.
the rust toolchain is not up to date and I last heard the directories are not set up right to download dependencies, so if you could compile elsewhere, that would simplify things. compile for x86_64-unknown-linux-gnu.
copying the executable into the folder of course takes some extra steps, as you can’t upload non-text files directly. usually people upload to assets and then download it inside the project using wget from the terminal.
set up a package.json file to run the program in the scripts.start part where it would say something like node server.js in a node.js app. or you could try to figure out the glitch.json method
Thanks I suspected something like that. I have the server as a binary as well so I don’t actually have to build it. I get a feeling it won’t run here too easily.
Glitch has rustup installed so you can quite easily update rustc to the latest version, however glitch’s default (1.32.0 I think?) might be good enough for you (bear in mind 1.70.0 is the latest) in which case you won’t need to install anything extra. By default glitch’s rustc installation is in /opt/multirust/rustc but you donpt have write access to that so you need to install into /tmp - the target dir is also in /opt so you need to have that in /tmp as well, unless you don’t need a lot of disk space for compilation in which case you can have your target dir in /app.
You’ll need to run the following in your install script: mkdir -p /tmp/rust && mkdir -p /tmp/rust/rustup && mkdir -p /tmp/rust/cargo && mkdir -p /tmp/rust/target && export RUSTUP_HOME=/tmp/rust/rustup && export CARGO_HOME=/tmp/rust/cargo && export CARGO_TARGET_DIR=/tmp/rust/target && rustup update stable
Of course feel free to change where those dirs are. Your start script would just be cargo run I’d imagine. Both these scripts should be in glitch.json - I canpt remember exactly how itps laid out but Glitch: The friendly community where everyone builds the web has some info on it iirc.
I’ve found that these env vars that you set in your install script don’t always stick around though, so you might have to set them again in your start script before running cargo build.
I’ve never built a web server in rust before so i have no idea if this’d work, but the process as a whole did work well when i was trying out the new fastly compute@edge stuff.
Hopefully this will help in some way