Skip to content

Commit

Permalink
[BUGFIX #4] Deploy rust without docker
Browse files Browse the repository at this point in the history
  • Loading branch information
nrs23 committed Nov 9, 2023
1 parent 2eb1a77 commit f0ed61e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Similar advice is available from government sources on a subscription basis, mos

# TODOs

- [] Build a decent docker template for the rust API [KN 4/11/23]
- [] Set up CI to deploy to digitalocean droplet using ssh and docker
See https://github.com/nseymoursmith/waterlogged-prototype/issues

# User flow

Expand Down
29 changes: 29 additions & 0 deletions deploy-rust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

git pull
if [ $? != 0 ]; then
echo "git pull failed, check the server logs!"
exit 1
fi

./stop-api.sh

if ! [ -d "$HOME/waterlogged-prototype/dockerised-rust-api/" ]; then
echo 'docker app directory does not exist!'
exit 1
fi

cd $HOME/waterlogged-prototype/dockerised-rust-api/
cargo build --release
if [ $? != 0 ]; then
echo "cargo build failed, check the server logs!"
exit 1
fi

./target/release/api-example &

PID=$!

echo "kill $!" > ../stop-api.sh

chmod +x ../stop-api.sh

1 comment on commit f0ed61e

@nrs23
Copy link
Contributor Author

@nrs23 nrs23 commented on f0ed61e Nov 9, 2023

Choose a reason for hiding this comment

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

Tested and works on the Digital Ocean droplet.

Will note that this method of capturing the PID of the process might not be the most robust ever, particularly if someone kills the process without using the stop-api.sh script, and then that script gets called anyway - in which case it could in rare cases stop something else. I'm happy to do a better job of it further down the line if we decide this is a good direction to go.

Please sign in to comment.