Compare commits

..

13 Commits

Author SHA1 Message Date
d8d38e0908
dude wtf
Signed-off-by: Pratyush Desai <pratyush.desai@liberta.casa>
2025-04-16 00:21:07 +05:30
0c44136f1a Merge remote-tracking branch 'origin/master' into website 2025-04-16 00:13:42 +05:30
d6eb2a1b25 Merge pull request 'containerize' (#20) from calm-steam/GameServerSupervisor:containerize into master
Reviewed-on: #20
2025-03-05 16:16:04 +01:00
0b622ce3ea
add step to sync host 2025-02-23 14:45:44 +05:30
bfac5a22eb
modify readme 2025-02-19 10:28:54 +05:30
2e114fef44
change variable name 2025-02-18 23:58:19 +05:30
e16a565c0c
add Dockerfile 2025-02-18 23:57:08 +05:30
8251fecf9a Merge pull request 'unit-testing' (#19) from calm-steam/GameServerSupervisor:unit-testing into master
Reviewed-on: #19
Reviewed-by: Pratyush Desai <pratyush.desai@liberta.casa>
2025-02-18 19:07:37 +01:00
07c1a2d8d6
fix readme 2025-02-16 16:06:06 +05:30
9f82e689a1
modify readme 2025-02-16 16:05:58 +05:30
9cec170f62
add webpanel/test_models.py as example 2025-02-16 16:05:47 +05:30
98b9574c67
delete webpanel/tests.py 2025-02-16 16:05:31 +05:30
7dc24f1456
remove docker reference in readme 2025-02-16 16:04:51 +05:30
9 changed files with 148 additions and 31 deletions

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM python:3.10-alpine
ARG supervisor_dir="/usr/src/GameServerSupervisor"
RUN mkdir -p $supervisor_dir
WORKDIR $supervisor_dir
COPY . $supervisor_dir
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 80

View File

@ -1,10 +1,23 @@
# GibCasa GameServerSupervisor
## Prerequisites
## Table of Contents
- [Installation using venv](#installation-using-venv)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Installation using Podman](#installation-using-podman)
- [Prerequisites](#prerequisites-1)
- [Installation](#installation-1)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
## Installation using venv
### Prerequisites
Python 3.10 or above
## Installation
### Installation
1. Clone the repository:
```bash
@ -22,19 +35,80 @@ Python 3.10 or above
```bash
pip install -r requirements.txt
```
5. Run tests:
```bash
./manage.py test
```
6. Run migrations:
```bash
./manage.py migrate
```
7. Create admin user:
```bash
./manage.py createsuperuser
```
8. Run server:
```bash
./manage.py runserver
```
## Installation using Podman
### Prerequisites
Podman
### Installation
1. Clone the repository:
```bash
git clone https://git.com.de/GibCasa/GameServerSupervisor
```
2. Build the image:
```bash
podman build . -t supervisor-image
```
3. Run a container in an interactive shell:
```bash
podman run -it --network=host localhost/supervisor-image sh
```
4. Run tests:
```bash
./manage.py test
```
5. Run migrations:
```bash
python manage.py migrate
./manage.py migrate
```
6. Create admin user:
```bash
python manage.py createsuperuser
./manage.py createsuperuser
```
7. Run server:
```bash
python manage.py runserver
./manage.py runserver
```
* visit http://localhost:8000 for /public and
http://localhost:8000/admin/ to login via the superuser credentials
* will need docker running
-------------
To live sync host directory with container folder, in Step 3:
```bash
podman run --network=host -itv /host/src/path:/usr/src/GameServerSupervisor supervisor-image sh
```
`/host/src/path` is the absolute path to the repository in the host machine.
## Usage
* Visit http://localhost:8000 for /public and
http://localhost:8000/admin/ to login via the superuser credentials
## Contributing
1. Fork the repository.
2. Create a new branch: `git checkout -b feature-name`.
3. Make your changes.
4. Push your branch: `git push origin feature-name`.
5. Create a pull request.
## License
This project is licensed under the [AGPL](https://www.gnu.org/licenses/agpl-3.0.html).

View File

@ -3,6 +3,7 @@ certifi==2024.12.14
charset-normalizer==3.4.1
Django==5.1.5
idna==3.10
pillow==11.2.1
podman==5.2.0
requests==2.32.3
sqlparse==0.5.3

View File

@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Game Server Supervisor{% endblock %}</title>
<title>{% block title %}GibCasa{% endblock %}</title>
<style>
* {
margin: 0;
@ -165,12 +165,12 @@
font-size: 14px;
}
.game-box img {
/* .game-box img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 5px;
}
} */
</style>
</head>
@ -189,15 +189,15 @@
<a href="{% url 'games' %}">Games</a>
</div>
</div>
</div class="navbar>
<!-- <div class="right">
<div class="search-box">
</div class="navbar">
<!-- <div class="right"> -->
<!-- <div class="search-box">
<input type="text" placeholder="Search...">
</div>
<a href="#">Auth / Settings</a> -->
</div> -->
<!-- <a href="#">Auth / Settings</a> -->
<!-- <div class="profile">Dp</div> -->
</div>
</div>
<!-- </div> -->
</div>
<div class="content">
{% block content %}{% endblock %}
@ -205,7 +205,7 @@
<footer>
<a href="https://ozFrags.net">Other Communities</a>
<a href="https://liberta.casa/rules.html">Terms of Service</a>
<a href="https://liberta.casa/rules.html">Terms of Service WIP</a>
<a href="#">License: AGPLish</a>
<a href="#">Contribute (WIP)</a>
<a href="https://liberta.casa/gamja/#gibcasa">Support</a>

View File

@ -16,16 +16,30 @@
</nav> -->
<div class="game-detail">
<div class="game-image">
<img src="{{ game.image_url }}" alt="{{ game.name }}">
<div class="game-box" style="width: 150px; text-align: center;">
<a href="{% url 'game_detail' game.name %}">
<img src="{{ game.thumbnail.url }}" alt="{{ game.name }}" style="width: 100%; height: auto;">
<p>{{ game.name }}</p>
</a>
</div>
<div class="active-servers">
{% if active_servers %}
{% for server in active_servers %}
<fieldset class="server-box">
<legend>Server: {{ game.name }}</legend>
<div class="server-details">
<p><strong>IP Address:</strong> {{ server.ip_address }}</p>
<p><strong>Port:</strong> {{ server.port }}</p>
<p><strong>Status:</strong> Online</p>
</div>
</fieldset>
{% endfor %}
{% else %}
<p>No active servers found for this game.</p>
{% endif %}
</div>
<div class="game-info">
<p>Pull data from some open API to populate information about the game and render it.</p>
<ul>
<li>🔹 <strong>Active:</strong> Non-full, non-empty servers with connection info, map, and player count</li>
<li>🔹 <strong>All Active:</strong> List of all active servers</li>
<li>🔹 <strong>Stopped:</strong> Available upon request</li>
</ul>
</div>
</div>
{% endblock %}

View File

@ -3,7 +3,7 @@
{% block title %}Games - Game Servers{% endblock %}
{% block content %}
<h2>Public Game Servers</h2>
<h2>Games</h2>
<div class="game-grid" style="display: flex; flex-wrap: wrap; gap: 10px;">
{% for game in games %}

11
webpanel/test_models.py Normal file
View File

@ -0,0 +1,11 @@
from django.test import TestCase
from webpanel.models import Game
class GameTestCase(TestCase):
def setUp(self):
Game.objects.create(name="Assassin's Creed")
def test_game_creation(self):
assassins = Game.objects.get(name="Assassin's Creed")
assert str(assassins) == "Assassin's Creed"

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@ -13,4 +13,10 @@ def games(request):
def game_detail(request, game_name):
print(f"Looking for game: {game_name}")
game = get_object_or_404(Game, name=game_name)
return render(request, 'webpanel/game_detail.html', {'game': game})
servers = Server.objects.filter(game=game)
for server in servers:
server.sync_status()
dormant_servers = servers.filter(status='offline')
active_servers = servers.filter(status='online')
return render(request, 'webpanel/game_detail.html', {'game': game,
'active_servers': active_servers, 'dormant_servers': dormant_servers})