Skip to content

feat: add supervisord conf #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions supervisor_generate_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

SYMBOLS_URL="https://history.pyth-lazer.dourolabs.app/history/v1/symbols"
TMP_FILE=$(mktemp)

# Download and save to temporary file
curl -s "$SYMBOLS_URL" | jq -c '.[:40]' > "$TMP_FILE"

# Count symbols
SYMBOLS_COUNT=$(jq -r 'length' "$TMP_FILE")

mkdir -p /etc/supervisor/conf.d
: > /etc/supervisor/conf.d/real_time_pricing_oracle.conf

COUNTER=1
i=0
while [ "$i" -lt "$SYMBOLS_COUNT" ]; do
GROUP=$(jq -c ".[$i:$((i+4))]" "$TMP_FILE")

CHANNEL=$(echo "$GROUP" | jq -r '.[0].min_channel')
PRICE_FEEDS=$(echo "$GROUP" | jq -r '[.[].name] | join(",")')

cat >> /etc/supervisor/conf.d/real_time_pricing_oracle.conf <<EOL
[program:symbol-fetcher-$COUNTER]
command=env ORACLE_WS_URL="$ORACLE_WS_URL" \
ORACLE_AUTH_HEADER="$ORACLE_AUTH_HEADER" \
SOLANA_CLUSTER="$ORACLE_SOLANA_CLUSTER" \
ORACLE_PRICE_FEEDS="$PRICE_FEEDS" \
ORACLE_CHANNEL="$CHANNEL" \
ephemeral-pricing-oracle
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0

EOL

COUNTER=$((COUNTER+1))
i=$((i+4))
done

rm "$TMP_FILE"
echo "Generated $((COUNTER-1)) Oracle supervisor configurations"
16 changes: 16 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[unix_http_server]
file=/tmp/supervisor.sock

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[supervisord]
nodaemon=true
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid

[include]
files = /etc/supervisor/conf.d/*.conf

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface