Assetto Server Manager

repository·master·Indexed 18 days ago

https://github.com/justapenguin/assetto-server-manager

A web interface for managing Assetto Corsa servers, featuring race mode presets, live timings, championship management, and content uploading. It supports manual installation on Linux and Windows, Docker deployment via the seejy/assetto-server-manager image, and automated server installation using steamcmd. The manager includes configurable data storage options (BoltDB or JSON), TLS support for HTTPS, and a premium Lua plugin system for custom championship hooks.

Tokens
22.6K
Snippets
63
Records
85
Agent score
58%

What's inside assetto-server-manager

  1. How Lua plugins and hooks work

    master

    Lua plugins allow you to run custom scripts through hooks triggered by Server Manager (SM) events.

    Execution Flow:

    1. An event occurs in the SM UI (e.g., the 'Event Start' button is pressed).
    2. The SM backend calls a specific Lua function (e.g., onEventStart) and sends the event data encoded as JSON.
    3. The Lua script receives the data, decodes it into a Lua Table, and can modify the contents.
    4. The Lua script encodes the modified data back to JSON and returns it to the backend.
    5. The backend uses the (potentially modified) data to execute the event.

    Important Constraints:

    • Type Fidelity: While Lua is not strictly typed, the backend is written in Go and is strictly typed. When modifying data in a Lua Table, you must keep the data types consistent. For example, do not change an int value to a float.
    • JSON Handling: The backend handles JSON encoding/decoding within the Lua functions. Do not modify the existing encoding/decoding logic, as this will break the integration.
    Event Start button is pressed in the SM UI
    Backend calls Lua function onEventStart and sends the configured event encoded as json
    Lua code can be used to modify the event
    Lua encodes the event back to json and returns it to the backend
    Backend starts the event
  2. Install Assetto Server Manager via Docker

    master

    The Docker image seejy/assetto-server-manager is available and includes steamcmd pre-installed. It is recommended to use docker-compose for setup.

    Important: If you are using a directory volume for the server install, you must create the directory on your host machine before running docker-compose up to ensure correct permissions.

    You must provide a config.yml file to mount into the container. You can find an example here.

    version: "3"
    
    services:
      server-manager:
        image: seejy/assetto-server-manager:latest
        ports:
        # the port that the server manager runs on
        - "8772:8772"
        # the port that the assetto server runs on (may vary depending on your configuration inside server manager)
        - "9600:9600"
        - "9600:9600/udp"
        # the port that the assetto server HTTP API runs on.
        - "8081:8081"
        # you may also wish to bind your configured UDP plugin ports here.
        volumes: 
        # volume mount the entire server install so that 
        # content etc persists across restarts
        - ./server-install:/home/assetto/server-manager/assetto
        
        # volume mount the config
        - ./config.yml:/home/assetto/server-manager/config.yml
  3. Install Assetto Server Manager manually

    master

    To install the server manager directly on your host machine (Linux or Windows):

    1. Download the latest release from the releases page.
    2. Extract the release files.
    3. Edit the config.yml file to your preferences.
    4. Set up the Assetto Corsa server files using one of two methods:
      • Manual Copy: Copy the server folder from your Assetto Corsa installation into the directory specified in your config.yml.
      • SteamCMD: Ensure steamcmd is installed and in your $PATH, and configure your Steam username and password within config.yml.
    5. Start the application:
      • Linux: ./server-manager
      • Windows: server-manager.exe
    # Example startup commands
    ./server-manager
    # or on Windows
    server-manager.exe
  4. Run the race out converter

    master

    The race out converter transforms a race_out.json file into a standard Assetto Corsa server results file. To use the converter, follow these steps:

    1. Prepare the input file: Copy your race_out.json file into the converter's directory. The filename must be exactly race_out.json.
    2. Map player names to GUIDs: Edit the name_to_guid.json file. You must add the names of all players from the session along with their corresponding GUIDs.
      • Important: The player name in name_to_guid.json must exactly match the name used in the race_out.json file.
    3. Execute the converter: Run the race-out-converter executable. The tool will process the files and output a standard server results file.
    # Example workflow
    # 1. Place race_out.json in the directory
    # 2. Update name_to_guid.json with exact player names and GUIDs
    # 3. Run the executable
    ./race-out-converter
  5. Build Assetto Server Manager from source

    master

    To build the project from source (optimized for Linux), follow these steps:

    1. Prerequisites:
      • Install Go 1.13.
      • Install Node.js 12.
    2. Clone and Navigate:
      • Clone the repository to your $GOPATH using go get.
      • Change directory to the repository root: $GOPATH/src/github.com/JustaPenguin/assetto-server-manager.
    3. Configure:
      • Create config.yml in assetto-server-manager/cmd/server-manager by copying config.example.yml.
      • Note: You must configure critical settings like the steamcmd path and default account information in config.yml before running.
    4. Build and Run:
      • Use the provided Makefile commands to build assets and run the server.
    # Clone the repository
    go get -u github.com/JustaPenguin/assetto-server-manager/...
    
    # Move to the repository root
    cd $GOPATH/src/github.com/JustaPenguin/assetto-server-manager
    
    # Build and run
    export GO111MODULE=on
    make clean
    make assets
    make asset-embed
    make run
  6. Update Assetto Server Manager

    master

    When updating to a new version, follow these steps to prevent data loss:

    1. Backup: Back up your current Server Manager database and config.yml.
    2. Download: Get the latest version from the releases page.
    3. Extract: Unzip the new version.
    4. Review Changes: Read the Changelog between your current version and the new version. Configuration changes may be required.
    5. Apply Config: Make any necessary adjustments to your config.yml based on the changelog.
    6. Replace Binary: Replace your existing OS-specific Server Manager executable with the new one.
    7. Restart: Start the new Server Manager executable.
  7. Post-installation optimization for Content and Weather

    master

    To enable full functionality of the Server Manager, perform the following:

    • Track Management: Upload your entire Assetto Corsa content/tracks folder to the Server Manager. This ensures track images, layouts, and mod tracks are correctly displayed.
    • Weather (Sol): Install Sol locally and upload your Sol weather files to the Server Manager to enable Day/Night cycles and advanced weather features.
  8. Configure Entrant Lists and Driver Auto-completion

    master

    The RaceSetup class provides automated logic for managing the list of drivers (entrants) in a race:

    • Auto-completion: Uses a possibleEntrants dataset to allow users to select driver names from an .entrant-autofill dropdown, which then automatically populates the driver's Name, Team, and GUID.
    • Dynamic Car/Skin/Setup Loading: When a car is selected for an entrant, the system automatically updates the available skins and fixed setups for that specific car model.
    • Skin Previews: Attempts to fetch and display a preview.jpg for the selected car skin from /content/cars/{car}/skins/{skin}/preview.jpg.
    • Entrant Addition: New entrants can be added in bulk. The system clones an #entrantTemplate and preserves certain settings (like the previously chosen car or skin) to speed up entry list creation.
  9. How Lua hooks work in Assetto Server Manager

    master

    Lua hooks allow developers to implement custom logic for live events occurring during a server session. These hooks are triggered by specific server events (like chat messages).

    Key characteristics of these hooks:

    • Non-blocking: Most hooks (like onChat) do not block the main server manager execution, allowing them to run alongside the manager.
    • Event-driven: They are called automatically when specific actions occur in the game or via the API.
    • Data Access: Event data is often passed as encoded strings (e.g., JSON) which must be decoded using the provided json module to be usable.
  10. Manage Championship Entrants and Points

    master

    The manager allows for dynamic management of race entrants and championship scoring:

    • Adding Entrants: Use the .addEntrant button to add new entrant slots. This automatically generates point positions based on the defaultPoints.Places configuration.
    • Point Scaling: When adding entrants, the system calculates the required number of point positions to match the current number of visible entrants.
    • Team Points: If an entrant is marked as a team (.entrant-team), the UI reveals options for points-transfer.