fix memory leak and add example bare metal installer
This commit is contained in:
@@ -207,7 +207,7 @@ server_start :: proc(server: ^Server) -> bool {
|
||||
// Spawn a new thread for this connection
|
||||
t := thread.create(connection_worker_thread)
|
||||
if t != nil {
|
||||
t.init_context = context
|
||||
//t.init_context = context // We dont actually need need to share the main threads context
|
||||
t.data = conn_data
|
||||
thread.start(t)
|
||||
} else {
|
||||
@@ -272,6 +272,9 @@ handle_connection :: proc(server: ^Server, conn: net.TCP_Socket, source: net.End
|
||||
context.allocator = request_alloc
|
||||
defer context.allocator = old
|
||||
|
||||
// Reset the temp allocator each request
|
||||
defer free_all(context.temp_allocator)
|
||||
|
||||
request, parse_err := parse_request(conn, request_alloc, server.config)
|
||||
|
||||
// Handle parse errors
|
||||
|
||||
72
ubuntu-baremetal-install-example.sh
Normal file
72
ubuntu-baremetal-install-example.sh
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
apt update
|
||||
apt upgrade -y
|
||||
|
||||
# Install Deps to build and install jormun
|
||||
echo 'Installing build deps'
|
||||
sudo apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
g++ \
|
||||
librocksdb-dev \
|
||||
libsnappy-dev \
|
||||
liblz4-dev \
|
||||
libzstd-dev \
|
||||
zlib1g-dev \
|
||||
libbz2-dev \
|
||||
curl \
|
||||
clang \
|
||||
git
|
||||
|
||||
# Install Odin compiler
|
||||
curl -Lo /tmp/odin.tar.gz https://github.com/odin-lang/Odin/releases/download/dev-2026-02/odin-linux-amd64-dev-2026-02.tar.gz \
|
||||
&& tar -xzf /tmp/odin.tar.gz -C /tmp \
|
||||
&& mv /tmp/odin-linux-amd64-nightly+2026-02-04 /opt/odin \
|
||||
&& ln -s /opt/odin/odin /usr/local/bin/odin \
|
||||
&& chmod +x /opt/odin/odin \
|
||||
&& odin version \
|
||||
&& rm /tmp/odin.tar.gz
|
||||
|
||||
# Install Caddy
|
||||
echo 'Installing Caddy'
|
||||
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
|
||||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
||||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
|
||||
chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
||||
chmod o+r /etc/apt/sources.list.d/caddy-stable.list
|
||||
sudo apt update
|
||||
sudo apt install caddy
|
||||
|
||||
echo 'Creating Caddyfile'
|
||||
# caddy update Caddyfile
|
||||
cat <<EOF > /etc/caddy/Caddyfile
|
||||
DOMAINGOESHERE.COM {
|
||||
handle {
|
||||
reverse_proxy 127.0.0.1:8002
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Actually install jormun
|
||||
echo 'Cloning, building, and installing Jormun DB'
|
||||
# clone the project
|
||||
git clone https://sweetapi.com/biondizzle/jormun-db.git
|
||||
cd jormun-db
|
||||
|
||||
# Build and install the project
|
||||
make install
|
||||
|
||||
# Copy over the systemd service
|
||||
cp ./jormundb.service /lib/systemd/system/jormundb.service
|
||||
|
||||
# Firewall stuff
|
||||
echo 'Opening required ports'
|
||||
ufw allow 80
|
||||
ufw allow 443
|
||||
|
||||
# Create the data directory
|
||||
mkdir -p /srv/jormundb/data
|
||||
|
||||
echo 'Enabling/Starting the JormunDB and Caddy Services'
|
||||
systemctl enable --now jormundb.service
|
||||
systemctl enable --now caddy.service
|
||||
Reference in New Issue
Block a user