#!/usr/bin/env bash

. ./cmd/env

start() {
    if [[ ! -z "$OB_CMD_ARGS" ]]; then
        ob_compose up -d $OB_CMD_ARGS
    else
        ob_compose up -d
    fi
}


run_start() {
    unset ERR
    start || ERR=$?
    if [[ $ERR > 0 ]]; then
        error "We ran into an error starting OSINTBuddy."
        exit 1
    else
        if [[ ! -z "$OB_CMD_ARGS" ]]; then
            success "Starting OSINTBuddy $OB_CMD_ARGS..."
            # ob_compose logs -f $OB_CMD_ARGS
        else
            success "Starting OSINTBuddy..."
            # ob_compose logs -f
            success "After JanusGraph connects to ScyllaDB and Solr, the app is ready for use."
            success "Please allow a few minutes for JanusGraph to finish starting up."
            echo ""
            info "To monitor when JanusGraph is ready, run: ./launcher logs janus"
            print_access_urls
        fi
        exit 0
    fi
}

run_start