Skip to content

maestro-server/websocket-app

Repository files navigation

Maestro Server

Maestro Server is an open source software platform for management and discovery servers, apps and system for Hybrid IT. Can manage small and large environments, be able to visualize the latest multi-cloud environment state.

Demo

To test out the demo, Demo Online

Maestro Server - WebSocket App

Centrifugo server. It is a websocket + rest server, the websocket is used by client to get a real time notification, and the rest is used by internal maestro do send a notification to the client.

  • Client notification using websockets

See Centrifugo project |

Build Setup

# Generate config
docker run maestroserver/websocket-maestro centrifugo genconfig

# Run websocket
docker run -e MAESTRO_WEBSOCKET_SECRET='secret' -e MAESTRO_SECRETJWT='jwttoken' maestroserver/websocket-maestro

# Run centrifugo with admin enabled
docker run -e CENTRIFUGO_ADMIN='pass' -e CENTRIFUGO_ADMIN_SECRET='jwttoken' maestroserver/websocket-maestro

WS Endpoints

Client Acess

var centrifuge = new Centrifuge('ws://{server}/connection/websocket');

centrifuge.subscribe("news", function(message) {
    console.log(message);
});

centrifuge.connect();

Backend Access

import json
import requests

command = {
    "method": "publish",
    "params": {
        "channel": "maestro#${ID-USER}", 
        "data": {
            "notify": { // call notify
                "title": "<string>",
                "msg": "<string>",
                "type": "danger|warning|info|success"
            },
            "event": {
                "caller": "<string>" //custom event on client
            }
        }
    }
}

api_key = "${MAESTRO_WEBSOCKET_SECRET}"
data = json.dumps(command)
headers = {'Content-type': 'application/json', 'Authorization': 'apikey ' + api_key}
resp = requests.post("https://{server}/api", data=data, headers=headers)
print(resp.json())

Websocker app - Architecture

arch

Env variables

Env Variables Example Description
MAESTRO_WEBSOCKET_SECRET backSecretToken Token to authenticate backends apps
MAESTRO_SECRETJWT frontSecretToken Token to autheticate front end users
CENTRIFUGO_ADMIN adminPassword Admin password
CENTRIFUGO_ADMIN_SECRET adminSecretToken Token to autheticate administrator users
CENTRIFUGO_TLSAUTO true Auto SSL using Let Encrypt
CENTRIFUGO_TLSAUTO_HTTP true Auto SSL using AcmeV1 Let Encrypt
CENTRIFUGO_TLS_PORT :80 Can be used to set address for handling http_01 ACME challenge, default value is :80
CENTRIFUGO_TLS true Using dev ssl certs to run custom certs
CENTRIFUGO_TLS_KEY /tmp/certs/server.key Full path ssl key (Expose by folder bind on docker)
CENTRIFUGO_TLS_CERT /tmp/certs/server.key Full path ssl certs

PS: Admin only will be enabled if Centrifugo admin and centrifugo admin secret it's setup.

Contribute

Are you interested in developing Maestro Server, creating new features or extending them?

We created a set of documentation, explaining how to set up your development environment, coding styles, standards, learn about the architecture and more. Welcome to the team and contribute with us.

See our developer guide

Contact

We may be able to resolve support queries via email. Please send me a message here

Donate

I have made Maestro Server with my heart, think to solve a real operation IT problem. Its not easy, take time and resources.

The donation will be user to:

  • Create new features, implement new providers.
  • Maintenance libs, securities flaws, and technical points.

Buy Me A Coffee

Sponsor