AYON Service Host (ASH)

Last updated 5 months ago

Overview

Similar to farm nodes or workers, AYON uses dedicated workers to run addon services.

The AYON Service Host (ASH) is a dedicated AYON worker designed to host and manage AYON addon services, functioning similarly to farm nodes or workers.

ASH operates as a lightweight process that handles the launching of services defined by the administrator on the AYON Services page. It regularly checks the AYON server database for listed services and automatically starts any that are not running.

In addition, ASH offers a straightforward API, enabling services to report their status and receive configuration updates efficiently.

Run an ASH worker

There are two ways to run your ASH worker:

  1. Use the same stack as the server.

  2. Create a completely separate stack.

Notes:

  • Running an ASH requires having an AYON API Key beforehand. You can create an API Key once you run your AYON instance, either via the terminal as explained here or the web UI as explained here.

  • ASH requires the docker.sock file to be mounted as a volume to control the Docker process and spawn services.

  • Your ASH must be able to reach your server; otherwise, you'll encounter connection errors. (espcially when you are running the ASH from a separate docker stack)

Use the same stack as the server

Run ASH as part of your main Ayon stack by modifying the Docker compose file in your self-hosted AYON setup.

Steps:

  1. Open docker-compose.yml inside your ayon-docker clone.

  2. Add the following section at the end of the services section (update the AYON_API_KEY to match yours):

      worker:
        image: ynput/ayon-ash:latest
        hostname: worker01
        restart: unless-stopped
        network_mode: host
        depends_on:
          - server
        volumes:
          - "/var/run/docker.sock:/var/run/docker.sock"
        environment:
          - "AYON_API_KEY=veryinsecureapikey"
          - "AYON_SERVER_URL=http://server:5000"
  3. Rebuild your Docker stack:

    docker compose up -d --build

Create a separate stack for ASH

Run ASH separately by creating a new Compose file or cloning the ASH repository. You can set this up on the same machine as the Ayon server or on a different machine, depending on your preference.

Steps:

  1. Create a directory (e.g., my-ayon-ash).

  2. Inside that directory, create an empty file named docker-compose.yml.

  3. Copy and paste the following code into the file (update AYON_SERVER_URL and AYON_API_KEY to match yours):

    version: "3.7"
    
    services:
      worker:
        image: ynput/ayon-ash:latest
        hostname: worker-02
        restart: unless-stopped
        network_mode: host
        volumes:
          - "/var/run/docker.sock:/var/run/docker.sock"
        environment:
          - "AYON_API_KEY=veryinsecureapikey"
          - "AYON_SERVER_URL=https://ayon.example.com"
  4. In the same directory as the Compose file, run:

    docker compose up -d

Troubleshooting

Handling Failed Services

In case a service fails to stop and remove its container, you may need to manually intervene to stop the orphaned containers.

Ayon service containers are easily identifiable by their naming convention. They use the service name with an aysvc_ prefix. This prefix allows you to quickly filter and manage Ayon service containers when working with Docker commands.

Run the following command to list all running Docker containers and filter the results to display only Ayon service containers.

$ docker ps | grep aysvc

6de503840bf1   ynput/ayon-webpublisher:1.1.0           "python -m ash_main"     1 second ago     Up Less than a second                                                                                     aysvc_webpublisher

4c6bed1c5915   ynput/ayon-ftrack-processor:1.4.4       "python -m processor"    20 seconds ago   Up 20 seconds                                                                                             aysvc_processor

Once you've identified the orphaned service containers, use the docker stop command to stop them individually. Replace <container_id> with the actual container ID of the orphaned container:

docker stop <container_id>

Since the containers are started with the --remove flag, they will be automatically removed once they are stopped.

Further Info

Feel free to check ASH discussions on our forums.