Skip to content

Multi launch #300

@ShutovKS

Description

@ShutovKS

At the root of the project, I have a script that allows you to run multiple instances with different authorizations at the same time. Perhaps this solution will be useful in your project as well. I am ready to finalize the script and make it universal for everyone.

Tell me, do you need such a feature? If so, I'll start work right away.

#!/bin/bash

TARGET_DIR=~/ai-studio-proxy
SAVED_AUTH_DIR="$TARGET_DIR/auth_profiles/saved"
BASE_PORT=2048
BASE_STREAM_PORT=3120
MY_SECRET_KEY="sk-dummy"

if [ ! -d "$SAVED_AUTH_DIR" ]; then
    echo "❌ Error: Folder $SAVED_AUTH_DIR not found!"
exit 1
fi

accounts=($(ls "$SAVED_AUTH_DIR"/*.json 2>/dev/null | xargs -n 1 basename -s .json))

if [ ${#accounts[@]} -eq 0 ]; then
    echo "❌ Error: Not found in the $SAVED_AUTH_DIR folder.json files!"
exit 1
fi

echo "🔍 Accounts found: ${#accounts[@]} (${accounts[*]})"

i=0
for acc in "${accounts[@]}"; do
  HOST_PORT=$((BASE_PORT + i))
  HOST_STREAM=$((BASE_STREAM_PORT + i))
  NAME="ai-proxy-$acc"
  
  echo "---------------------------------------------------"
  echo "🔄 Container launch [$((i+1))/${#accounts[@]}]: $acc"
  echo "📍 Port: $HOST_PORT | Stream: $HOST_STREAM"

docker stop "$NAME" 2>/dev/null || true
  docker rm "$NAME" 2>/dev/null || true
  
  docker run -d \
    --name "$NAME" \
    --restart unless-stopped \
    -p 127.0.0.1:$HOST_PORT:2048 \
    -p 127.0.0.1:$HOST_STREAM:3120 \
    -v "$SAVED_AUTH_DIR/$acc.json:/app/auth_profiles/active/$acc.json" \
    -e API_KEY=$MY_SECRET_KEY \
    -e SERVER_LOG_LEVEL=INFO \
    ai-studio-proxy:latest
    
  let i++
done

echo ""
echo "✅ Done! Containers running: $i"
echo "🔑 API Key for all: $MY_SECRET_KEY"
docker ps --filter "name=ai-proxy-"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions