Im using rust knightly, my code is compiling and working, now, I uploaded the code to the server, and my intention is to execute ROCKET_ENV=stage cargo run in background.
Im usin Amazon web services(AWS).
If i run the comand on a console and acces to the url
http://myapli_rust.com its works fine. The problem arrives when I close the console, the process finish and url doesnt work anymore sayin the the site cannot be reached.
If i do ROCKET_ENV=stage cargo run & doestn work neither.
If i run the binary like ./project is works fine till close terminal too
AWS is using a ubuntu OS
Thank in advantage
Disclaimer: I have never used AWS.
In a regular hosting service, I’d create a systemd unit that starts the compiled artifact instead of relying on cargo.
Can you explain me that steps.
I have added to init.d a sh that makes the steps, reboot the server, but stil didnt working.
cargo run in production.
cargo build --release and copy
target/release/<executable> to some appropriate place (e.g.
/usr/bin or some directory dedicated to your project on your server).
For Ubuntu/Debian based OSes you can use
cargo-deb to build your code as a Debian package and install it “properly” on the system.
For running it as a server, you can’t just run it from the shell. Even if you prevent termination of your executable with
nohup, it would still be super fragile, as nothing would monitor or restart it in case of problems. Proper solution would be to configure it as a systemd service.
Ok, i solved creating a system service putting it in init.d
I was doing test on a test server.