Skip to content

Commit

Permalink
Update readme & scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
joeoneil committed Dec 8, 2023
1 parent 5fad177 commit 127cf8a
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 58 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ To setup and launch a development environment, you can do the following:

There is a file called .env.template in the `./onboard` folder. Fill this in with appropriate values for the backend and frontend.



### Running outside a container

In onboard/frontend, run dotnet-run
In onboard/backend, run cargo run

The frontend will log errors about not being able to connect until the backend is up and running

### Building and Launching the Container

```
Expand Down
4 changes: 2 additions & 2 deletions dcu/.xinitrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ configure_display() {
. ~/.env
configure_display

openbox & compton & $(pulseaudio || echo "pulseaudio already started") &
~/publish/onboard >> ~/onboard.log 2>&1
openbox & compton & /usr/libexec/xdg-desktop-portal-gtk &
~/publish/onboard 2>&1 | systemd-cat -t devcade-onboard
13 changes: 0 additions & 13 deletions dcu/update.sh

This file was deleted.

38 changes: 0 additions & 38 deletions dcu/update_onboard.sh

This file was deleted.

11 changes: 6 additions & 5 deletions onboard/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

# Backend
# Allowed log levels: trace, debug, info, warn, error
RUST_LOG=
DEVCADE_API_DOMAIN=
DEVCADE_DEV_API_DOMAIN=
RUST_LOG= #Logging level for the backend
DEVCADE_API_DOMAIN= #URL for devcade API
DEVCADE_DEV_API_DOMAIN= #URL for devcade-dev API

# Frontend
# Allowed log levels: trace, verbose, debug, info, warn, error, fatal
FRONTEND_LOG=
VIEW_WIDTH=
FRONTEND_LOG= # Logging level for the frontend
VIEW_WIDTH=
VIEW_HEIGHT=
# Demo mode will not display games with certain tags (e.g. "CSH Only")
# Allowed values: true, false
DEMO_MODE=

# Shared
# Games data and shared sockets will be placed here
DEVCADE_PATH=
37 changes: 37 additions & 0 deletions onboard/build.py
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()
43 changes: 43 additions & 0 deletions onboard/onboard
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

0 comments on commit 127cf8a

Please sign in to comment.