Skip to content

Commit

Permalink
Merge pull request #1565 from KBVE/beta
Browse files Browse the repository at this point in the history
Preparing Release Branch
  • Loading branch information
h0lybyte committed May 16, 2024
2 parents 3272b73 + a87e51e commit 255573b
Show file tree
Hide file tree
Showing 13 changed files with 3,462 additions and 6 deletions.
8 changes: 6 additions & 2 deletions apps/atlas/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ RUN apt-get update && apt-get install -y \
python3-dev \
gnupg2 \
gnome-terminal \
gnome-session
gnome-session \
openbox \
openjdk-11-jdk

# Install Python and Poetry using deadsnakes PPA
RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y python3.12 python3.12-venv python3.12-distutils python3-pip && \
curl -sSL https://install.python-poetry.org | python3.12 -

# Download RuneLite
RUN wget -O /usr/local/bin/runelite.jar https://github.com/runelite/launcher/releases/download/2.7.1/RuneLite.jar

# Environment variables to configure
ENV HOME=/root \
DISPLAY=:1 \
Expand All @@ -45,7 +50,6 @@ RUN chmod +x /usr/local/bin/entrypoint.sh
# Install dependencies with Poetry
RUN poetry install


# Expose necessary ports
#EXPOSE 5900 6080 8000
EXPOSE 6080 8086
Expand Down
20 changes: 20 additions & 0 deletions apps/atlas/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ sleep 5
mkdir -p ~/.vnc
x11vnc -storepasswd 12345 ~/.vnc/passwd

# Update the xstartup script to run RuneLite
cat <<EOF > ~/.vnc/xstartup
#!/bin/sh
# Start GNOME session
gnome-session &
EOF


# Ensure the xstartup script has executable permissions
chmod +x ~/.vnc/xstartup

# Start the VNC server
# Added `-noxdamage` to avoid issues with compositing window managers that might cause the black screen
# Added `-verbose` for more detailed logs which might help in diagnosing issues
Expand All @@ -34,5 +45,14 @@ cp -r /usr/share/novnc/* /app/templates/novnc/
# Copy vnc.html to index.html
cp /app/templates/novnc/vnc.html /app/templates/novnc/index.html

# Start Openbox (window manager)
#openbox &

# Wait a bit to make sure Openbox starts
#sleep 5

# Start RuneLite
#java -jar /usr/local/bin/runelite.jar &

# Execute the command passed to the docker run
exec "$@"
1 change: 1 addition & 0 deletions apps/atlas/kbve_atlas/api/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .coindesk_client import CoinDeskClient
from .screen_client import ScreenClient
from .novnc_client import NoVNCClient
from .runelite_client import RuneLiteClient
29 changes: 29 additions & 0 deletions apps/atlas/kbve_atlas/api/clients/runelite_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import subprocess
import os
import asyncio
import logging

logger = logging.getLogger("uvicorn")

class RuneLiteClient:
def __init__(self, display=":20", jar_path="/usr/local/bin/runelite.jar"):
self.display = display
self.jar_path = jar_path

async def start_runelite_async(self):
env = os.environ.copy()
env["DISPLAY"] = self.display
try:
# Since subprocess.run is not async, use asyncio to run it in a thread pool
await asyncio.to_thread(
subprocess.run, ["java", "-jar", self.jar_path], env=env
)
logger.info("RuneLite started successfully.")
return "RuneLite started successfully."
except Exception as e:
logger.error(f"Failed to start RuneLite: {e}")
return f"Failed to start RuneLite: {e}"

async def close(self):
# This method is required by the KRDecorator's pattern, even if it does nothing
pass
6 changes: 5 additions & 1 deletion apps/atlas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from contextlib import asynccontextmanager

from kbve_atlas.api.clients import CoinDeskClient, WebsocketEchoClient, PoetryDBClient, ScreenClient, NoVNCClient
from kbve_atlas.api.clients import CoinDeskClient, WebsocketEchoClient, PoetryDBClient, ScreenClient, NoVNCClient, RuneLiteClient
from kbve_atlas.api.utils import RSSUtility, KRDecorator, CORSUtil, ThemeCore, BroadcastUtility

import logging
Expand Down Expand Up @@ -108,3 +108,7 @@ def bitcoin_price(price):
@kr_decorator.k_r("/poem", PoetryDBClient, "get_random_poem")
def poetry_db(poem):
return {"poem": poem}

@kr_decorator.k_r("/start-runelite", RuneLiteClient, "start_runelite_async")
def runelite_startup_message(startup_message):
return {"message": startup_message}

0 comments on commit 255573b

Please sign in to comment.