#!/usr/bin/env bash

source .venv/bin/activate || ( uv venv -p 3.12 && source .venv/bin/activate && uv pip install -e . )
source .env

if [[ -n $MEILI_SERVICE ]] ; then
if [[ -n $(pgrep meilisearch) ]] ; then
    echo meilisearch already running at PID: $(pgrep meilisearch)
else
    echo starting meilisearch server on https://localhost:7700
    mkdir -p logs
    if [[ ! -f '/etc/systemd/system/meilisearch.service' ]] ; then
	sudo cp scripts/meilisearch.service /etc/systemd/system/
        sudo systemctl daemon-reload
        sudo systemctl enable meilisearch
        sudo systemctl start meilisearch
    fi 
fi
fi



