-
Notifications
You must be signed in to change notification settings - Fork 175
/
run
executable file
·52 lines (42 loc) · 1.21 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Ensure all commands are run within this script's directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR"
# Kill any running API instances
PORT=8000
PID=$(lsof -t -i :$PORT)
if [ ! -z "$PID" ]; then
kill $PID
fi
# Ensure an environment file exists
if [ ! -f .env ]; then
cp .env.template .env
echo "Error: Please add your api keys to the .env file."
exit 1
fi
# Get the Node.js version
node_version=$(node --version | cut -d 'v' -f 2)
# Check if Node.js version is >= 20
version_ge() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
if version_ge "$node_version" "20"; then
echo "Node.js version ($node_version) is greater than or equal to 20."
else
echo "Error: Node.js version ($node_version) is less than 20."
exit 1
fi
# Check if Yarn is installed
if command -v yarn >/dev/null 2>&1; then
echo "Yarn is installed."
else
echo "Error: Yarn is not installed."
exit 1
fi
# Install and build evo.ninja
yarn
yarn build
# Start the API
yarn start:api > /dev/null 2>&1 &
echo "✓ evo.ninja running agent-protocol at localhost:$PORT"
# Disown the backgrounded process so it's not terminated when the script exits
disown
exit 0