Skip to content

Set up Manticore Locally

Chris edited this page Mar 8, 2024 · 3 revisions

Introduction

The focus of this wiki is launching Manticore on AWS. This is because you should not need to develop the Manticore project, just deploy it. However, if you need to make modifications, you will want to be able to run everything on your own computer for testing. This is what this page is for.

Setup

Spin up a virtual machine such as Ubuntu 18.04+ for all the programs to run in. You will need Docker, NPM, Node, Consul, Nomad, and Git installed. For Consul and Nomad you may use this script to download and set up on your VM:

CONSUL_VERSION=1.5.2
NOMAD_VERSION=0.9.3
#download consul and nomad and set them up
wget https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
unzip consul_${CONSUL_VERSION}_linux_amd64.zip
rm consul_${CONSUL_VERSION}_linux_amd64.zip
sudo mv consul /usr/bin/consul

wget https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip
unzip nomad_${NOMAD_VERSION}_linux_amd64.zip
rm nomad_${NOMAD_VERSION}_linux_amd64.zip
sudo mv nomad /usr/bin/nomad

The concept of agents and their arguments used to run them are already explained in other pages of this wiki, so they will only briefly be covered on this page. The idea is to run the Consul and Nomad agent programs in dev mode. This will cause them to run and function as both a server agent and a client agent, allowing a developer to only need a single machine to create a cluster.

Starting Consul

consul agent -dev -bind=<LOCAL IP> -client=<LOCAL IP>

Set the bind and client address values to your local IP. This will be the IP assigned to your machine by your local network. Using localhost may not work!

Starting Nomad

Nomad requires more configuration to setup correctly, so pass in a file as a config argument instead. This will be the contents of the config file:

bind_addr="<LOCAL IP>"

data_dir="/tmp/nomad"

consul {
    address = "<LOCAL IP>:8500" # Keep port 8500, but replace with your machine's IP
}

server {
    enabled = true
    bootstrap_expect = 1
}

client {
    enabled = true
    meta {
        "manticore" = true
        "job" = true
    }
    options {
        "docker.cleanup.image" = "false"
    }
}

Replace <LOCAL_IP> with your local IP address as before. This file tells Nomad where to find the Consul agent to connect to, assures that only one agent needs to run to form a server cluster, and that it is a Manticore and job agent, which allows the Manticore, Core and Generic HMI Docker containers to be executable on this machine.

Then, save the file as config.hcl and then run Nomad:

sudo nomad agent -config config.hcl

Manticore API Server

Download the Manticore Server project to your computer here. It can be run without being put in a Docker container, but that means it needs an extra environment variable. Create an .env file in the root directory of the project with the following:

NOMAD_IP_http=<LOCAL IP>

This will tell the server where to locate the Nomad client agent so that it may communicate with the cluster.

Start the server

Install dependencies and start the server:

npm install
npm start

Once running there will be a webpage available on http://localhost:4000 where you may test requesting jobs. Note that the first two job requests may fail because Manticore must download the SDL Core and Generic HMI Docker images first, which will take long enough for the job allocation timer to go past a healthy threshold and the job will fail.