-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
97 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/python3 | ||
|
||
|
||
def main(): | ||
import os | ||
import shutil | ||
import subprocess | ||
|
||
home_path = "/home/devcade" | ||
out_path = "/home/devcade/publish" | ||
|
||
|
||
if os.path.exists(f"{home_path}/publish.bak") and os.path.exists(out_path): | ||
shutil.rmtree(f"{home_path}/publish.bak") | ||
|
||
if os.path.exists(out_path): | ||
shutil.move(out_path, f"{home_path}/publish.bak") | ||
|
||
|
||
# build and move frontend | ||
os.chdir("./frontend") | ||
subprocess.run("dotnet publish -c Release -r linux-x64 --sc", shell=True) | ||
shutil.move("./bin/Release/net6.0/linux-x64/publish", home_path) | ||
shutil.move(f"{out_path}/onboard", f"{out_path}/frontend") | ||
|
||
# build and move backend | ||
os.chdir("../backend") | ||
subprocess.run("cargo build -r", shell=True) | ||
shutil.move("./target/release/backend", f"{out_path}/") | ||
|
||
os.chdir("..") | ||
# copy onboard shell script (definitely should add this to git lmao) | ||
shutil.copy2("./onboard", f"{out_path}/onboard") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
# This script runs and manages the onboard frontend and backend | ||
|
||
cd $HOME/publish | ||
|
||
backend_pid=-1 | ||
frontend_pid=-1 | ||
|
||
function cleanup() { | ||
if [ -n "$(ps -p $backend_pid -o pid=)" ]; then | ||
kill $backend_pid | ||
echo -e "Killed backend (pid $backend_pid)" | ||
fi | ||
if [ -n "$(ps -p $frontend_pid -o pid=)" ]; then | ||
kill $frontend_pid | ||
echo -e "Killed frontend (pid $frontend_pid)" | ||
fi | ||
exit 1 | ||
} | ||
|
||
./backend & | ||
backend_pid=$! | ||
|
||
./frontend & | ||
frontend_pid=$! | ||
|
||
# run 'cleanup' on exit | ||
trap 'cleanup' exit | ||
|
||
# run forever to keep handle on frontend and backend. | ||
# if this script is interrupted it will kill both the | ||
# frontend and backend. | ||
while [ 1 -eq 1 ]; do | ||
sleep 5 | ||
# if backend or frontend are not running, then kill the other and exit. | ||
if [ -z "$(ps -p $backend_pid -o pid=)" ]; then | ||
cleanup | ||
fi | ||
if [ -z "$(ps -p $frontend_pid -o pid=)" ]; then | ||
cleanup | ||
fi | ||
done |