remove local directory

This commit is contained in:
hrshtt
2025-08-20 10:18:12 +05:30
parent 9f9b5a5d17
commit 06ef626c08
12 changed files with 8 additions and 256 deletions

View File

@@ -30,7 +30,7 @@ jobs:
- name: Start Factorio server
run: |
cd fle/cluster/local
cd fle/cluster
bash run-envs.sh start -n 1
@@ -56,7 +56,7 @@ jobs:
- name: Check server status
run: |
cd fle/cluster/local
cd fle/cluster
docker compose -f docker-compose.yml ps
docker compose -f docker-compose.yml logs factorio_0
@@ -110,7 +110,7 @@ jobs:
- name: Show test logs on failure
if: failure()
run: |
cd fle/cluster/local
cd fle/cluster
echo "=== Factorio container logs ==="
docker compose -f docker-compose.yml logs factorio_0
@@ -120,5 +120,5 @@ jobs:
- name: Stop server
if: always()
run: |
cd fle/cluster/local
cd fle/cluster
bash run-envs.sh stop

View File

@@ -12,24 +12,17 @@ The system allows you to:
- Share scenarios across instances
- Choose between different scenarios (open_world or default_lab_scenario)
## Files
## `run-envs.sh`
- `run-envs.sh` - Main script for running and managing Factorio instances with options for scenario selection
- `create_docker_compose_config.py` - Generates Docker Compose configuration for multiple Factorio instances
- `factorio_server_login.py` - Automates the process of connecting to and initializing each server instance
- Main script for generating compose yaml
- Running and managing Factorio instances with options for scenario selection
## Setup and Usage
### Prerequisites
- Docker installed and running
- Python 3.x with required packages:
- PyYAML
- psutil
- pyautogui
- dotenv
- opencv-python-headless
- Factorio game client installed locally
- Optional: Factorio game client installed locally
### Managing Server Instances with run-envs.sh
@@ -79,19 +72,6 @@ The `run-envs.sh` script provides a convenient way to start, stop, and manage Fa
./run-envs.sh restart
```
### Creating Server Instances (Legacy Method)
1. Generate a Docker Compose configuration:
```bash
python create_docker_compose_config.py <number_of_instances>
```
For example, to create 4 instances:
```bash
python create_docker_compose_config.py 4
```
### Server Configuration
@@ -103,21 +83,6 @@ Each Factorio instance is configured with:
- Unique TCP port for RCON (starting at 27015)
- Choice of scenario (open_world or default_lab_scenario)
### Server Initialization
To connect to and initialize all server instances:
```bash
python factorio_server_login.py
```
This script will:
1. Detect running Factorio containers
2. Launch the Factorio client
3. Automatically connect to each server from the client (necessary to initialise the game servers)
4. Initialize necessary configurations
## Port Mappings
- Game ports (UDP): 34197 + instance_number
@@ -145,4 +110,3 @@ If you encounter issues:
1. Ensure Docker is running and has sufficient resources
2. Check container logs using `docker logs factorio_<instance_number>`
3. Verify port availability using `netstat` or similar tools
4. Adjust screen coordinates in `factorio_server_login.py` if automation fails

View File

@@ -1,41 +0,0 @@
services:
factorio:
image: 'factorio:latest'
platform: linux/amd64
environment:
- SAVES=/opt/factorio/saves
- CONFIG=/opt/factorio/config
- MODS=/opt/factorio/mods
- SCENARIOS=/opt/factorio/scenarios
- PORT=34197
- RCON_PORT=27015
volumes:
- type: bind
source: ./scenarios/default_lab_scenario
target: /opt/factorio/scenarios/default_lab_scenario
ports:
- '34198:34197/udp'
- '27015:27015/tcp'
restart: unless-stopped
user: factorio
#entrypoint: [ "bash", "/scenario.sh", "default_lab_scenario" ]
entrypoint: []
command: >
/opt/factorio/bin/x64/factorio
--start-server-load-scenario default_lab_scenario
--port 34197
--server-settings /opt/factorio/config/server-settings.json
--map-gen-settings /opt/factorio/config/map-gen-settings.json
--map-settings /opt/factorio/config/map-settings.json
--server-banlist /opt/factorio/config/server-banlist.json
--rcon-port 27015
--rcon-password "factorio"
--server-whitelist /opt/factorio/config/server-whitelist.json
--use-server-whitelist
--server-adminlist /opt/factorio/config/server-adminlist.json
--mod-directory /opt/factorio/mods
deploy:
resources:
limits:
cpus: '1'
memory: 512m

View File

@@ -1,19 +0,0 @@
volumes:
scenarios:
services:
factorio_1:
image: 'factoriotools/factorio:1.1.110'
volumes:
- type: bind
source: ./scenarios/default_lab_scenario
target: /opt/factorio/scenarios/default_lab_scenario
ports:
- '34198:34197/udp'
- '27016:27015/tcp'
restart: always
entrypoint: ["sh", "/scenario.sh", "default_lab_scenario"]
deploy:
resources:
limits:
cpus: '1'
memory: 512m

View File

@@ -1,109 +0,0 @@
import subprocess
import time
import yaml
import sys
from typing import Dict, Any
def generate_compose_config(num_instances: int, map: str) -> Dict[str, Any]:
services = {}
base_udp_port = 34197
base_tcp_port = 27000
for i in range(num_instances):
service_name = f"factorio_{i}"
services[service_name] = {
"image": "factorio",
"pull_policy": "never",
"platform": "linux/amd64",
"environment": [
"SAVES=/opt/factorio/saves",
"CONFIG=/opt/factorio/config",
"MODS=/opt/factorio/mods",
"SCENARIOS=/opt/factorio/scenarios",
f"PORT={base_udp_port}",
"RCON_PORT=27015",
],
"volumes": [
{
"type": "bind",
"source": "../scenarios/default_lab_scenario",
"target": "/opt/factorio/scenarios/default_lab_scenario",
},
{
"type": "bind",
"source": "../scenarios/open_world",
"target": "/opt/factorio/scenarios/open_world",
},
{
"type": "bind",
"source": "~/Applications/Factorio.app/Contents/Resources/mods",
"target": "/opt/factorio/mods",
},
{
"type": "bind",
"source": "../../data/_screenshots",
"target": "/opt/factorio/script-output",
},
],
"ports": [
f"{base_udp_port + i}:{base_udp_port}/udp",
f"{base_tcp_port + i}:27015/tcp",
],
"restart": "unless-stopped",
"user": "factorio",
"entrypoint": [],
"command": " ".join(
[
"/opt/factorio/bin/x64/factorio",
f"--start-server-load-scenario {map}",
f"--port {base_udp_port}",
"--server-settings /opt/factorio/config/server-settings.json",
"--map-gen-settings /opt/factorio/config/map-gen-settings.json",
"--map-settings /opt/factorio/config/map-settings.json",
"--server-banlist /opt/factorio/config/server-banlist.json",
"--rcon-port 27015",
'--rcon-password "factorio"',
"--server-whitelist /opt/factorio/config/server-whitelist.json",
"--use-server-whitelist",
"--server-adminlist /opt/factorio/config/server-adminlist.json",
"--mod-directory /opt/factorio/mods",
"--map-gen-seed 44340",
]
),
"deploy": {"resources": {"limits": {"cpus": "1", "memory": "1024m"}}},
}
return {"services": services}
def setup_docker_compose(num_instances: int, map: str):
"""Generate and write docker-compose.yml, then start the containers"""
config = generate_compose_config(num_instances, map)
# Write the configuration to docker-compose.yml
with open(f"docker-compose-{num_instances}.yml", "w") as f:
yaml.dump(config, f)
# Start the containers
subprocess.run(
["docker-compose", "up", "-d", f"docker-compose-{num_instances}.yml"]
)
# Wait for containers to be ready
time.sleep(10)
if __name__ == "__main__":
num_instances = 33
map = "open_world" # or default_lab_scenario
if len(sys.argv) != 2:
print("Usage: python create_docker_compose_config.py <number_of_instances>")
else:
num_instances = int(sys.argv[1])
setup_docker_compose(num_instances, map)
print(
f"Created docker-compose-{num_instances}.yml for {num_instances} Factorio instances."
)

View File

@@ -1,43 +0,0 @@
services:
factorio_0:
command: /opt/factorio/bin/x64/factorio --start-server-load-scenario open_world
--port 34197 --server-settings /opt/factorio/config/server-settings.json --map-gen-settings
/opt/factorio/config/map-gen-settings.json --map-settings /opt/factorio/config/map-settings.json
--server-banlist /opt/factorio/config/server-banlist.json --rcon-port 27015
--rcon-password "factorio" --server-whitelist /opt/factorio/config/server-whitelist.json
--use-server-whitelist --server-adminlist /opt/factorio/config/server-adminlist.json
--mod-directory /opt/factorio/mods --map-gen-seed 44340
deploy:
resources:
limits:
cpus: '1'
memory: 1024m
entrypoint: []
environment:
- SAVES=/opt/factorio/saves
- CONFIG=/opt/factorio/config
- MODS=/opt/factorio/mods
- SCENARIOS=/opt/factorio/scenarios
- PORT=34197
- RCON_PORT=27015
image: factorio
platform: linux/amd64
ports:
- 34197:34197/udp
- 27000:27015/tcp
pull_policy: never
restart: unless-stopped
user: factorio
volumes:
- source: ../scenarios/default_lab_scenario
target: /opt/factorio/scenarios/default_lab_scenario
type: bind
- source: ../scenarios/open_world
target: /opt/factorio/scenarios/open_world
type: bind
- source: ~/Applications/Factorio.app/Contents/Resources/mods
target: /opt/factorio/mods
type: bind
- source: ../../data/_screenshots
target: /opt/factorio/script-output
type: bind