Skip to content
Kneerunjun edited this page Apr 11, 2021 · 4 revisions

Srvauth is a dockered microservice

Its a microservice in a container, developed in GO. This is an handy add-on to your application running on your device to get your hands off from

  • device authentication
  • device registration

It can connect to the designated service api on the cloud and check for authentication and registration. Other worker containers can wait for this to finish and then either choose to continue / abort. Srvauth communicates via a socket, and with a fixed json message to let know the status.

Worker containers each can have their own halt socket that this service sends a message to.

What to expect on the listener socket ?

{
    "auth": true,
    "reg": true
}

Listeners can expect a short (512 MB, max) message on the halt.sock for communication from srvauth. This message denotes status of 2 things : Authentication success/ fail, Registration success / fail. Either of the cases the srvauth shall exit once it has deposited the message on all sockets. Srvauth container exits once it has done the job. Hence we have a lower memory footprint during the run.

Getting srvauth in your sequence of containers

version: '3'
# this can be then plugged to a larger yml while where you want all the services to work in a swarm
# here we are just making a file for a single service to run
services:
  srvauth:
    build: ${REPODIR}/srvauth
    volumes:
      - ${GOBINDIR}:${GOBINDIR}
      - /sys:/sys
      - ${TIMEZ}:${TIMEZ}
      - ${LCLTM}:${LCLTM}
      - ${LCLDIR}:${LCLDIR}
    #   this is where all your sockets will be placed, make sure your user id has write access to this directory
      - ${SOCKSDIR}:${SOCKSDIR}
    environment:
      - LOGF=${LCLDIR}/logs/srvauth.log
      - AUTHBASEURL=${AUTHBASEURL}
      - REGBASEURL=${REGBASEURL}
      - HALTSOCK=${SOCKSDIR}/halt.sock # comma separated path to sock files - this is where other services would be listening at 
      - USER=${OWNER}
      - RLYS=${RELAYS}
    tty: ${TTYSTDIN}
    stdin_open: ${TTYSTDIN}
    container_name: srvauth
    # command: ["tail", "-f", "/dev/null"]
    command: ["${REPODIR}/srvauth/srvauth","-flog=${FLOG}", "-verbose=${VERBOSE}"]