Files
hub/run.sh
T

74 lines
1.5 KiB
Bash

#!/bin/bash
source .venv/bin/activate
if [ -f .env ]; then
source .env
export REPLICATE_API_TOKEN
else
echo "No .env file found."
echo "Write a .env file with the variables: REPLICATE_API_TOKEN"
fi
case "$1" in
"")
data_dir=$(realpath ./local-data)
mkdir -p $data_dir
cd backend
python app.py $data_dir
;;
"cli")
node cli/main.js "$2"
;;
"test")
# Setup test data directory
mkdir -p test-data
rm -f test-data/horde.db
# Start backend in the background
cd backend
python app.py ../test-data &
BACKEND_PID=$!
echo "Started backend: $BACKEND_PID"
sleep 2
# Run tests
cd ../testing
bash signup.sh
#node login.js
node suite.js
# Finalize the backend server
kill $BACKEND_PID
;;
"debug")
# Debug doesn't work very well... I don't use it.
cd backend
python app.py &
cd ../frontend
# This can be skipped if chrome IS installed
export CHROME_EXECUTABLE=chromium
export BACKEND_URL="ws://localhost:5000"
flutter run -d chrome
# Close backend when debugger closes
kill $!
;;
"watch")
# requires 'inotify-tools' package
cd frontend
while inotifywait -r -e modify,create,delete lib; do
flutter build web
done
;;
*)
if [ -d "$1" ]; then
data_dir=$(realpath $1)
cd backend
python app.py $data_dir
else
echo "Error: unknown command or directory '$1'"
fi
;;
esac