The ActiveStack Gateway is a Node server that sets up a real-time socket server for clients wanting to connect to the ActiveStack backend.
The AS Gateway provides two usage methods:
npm install -g activestack-gateway. This method will make the
activestack-gatewayexecutable available on your path for starting from the command line.
npm install activestack-gateway. This method will make the gateway available to your project at runtime so you can control the gateway from your application.
If you installed the gateway with the global option then you'll have a new executable on your path:
To start the gateway server with default options run:
> activestack-gateway server|s
To start the gateway console to control an already running server run:
> activestack-gateway console|c
Once you've started the active stack control console you can issue these commands to control the server:
quit- to quit the console
restart- to restart the server
shutdown- to shut the server down
loglevel- set the log level # Not currently implemented
clientmessageresendinterval- print the client message resend interval configuration
clientcount- print the number of clients connected to the server
The AS Gateway allows several different configuration options. These can be specified using a customer configuration file.
# How often should server process send heartbeats to workers cluster.heartbeatInterval=1000 # How long before a worker times out and is restarted cluster.workerTimeout=5000 # DON'T KNOW cluster.watchdogInterval=1000 # Get warned when memory reaches this level cluster.memoryWarning.rss=1024 # Get warned when memory reaches this level cluster.memoryWarning.heapTotal=60 # Hard memory limit cluster.memoryLimit.rss=2048 # Hard memory limit cluster.memoryLimit.heapUsed=100 # How long to wait before worker is restarted cluster.workerRestartDelay=50 # Worker backoff cluster.maxRestartBackoff=10 # The number of workers to spawn. If not specified will use (numCPUs/2)+1 cluster.workerCount=2 # Logging level frontend.logLevel=info # Shutdown password frontend.shutdownCode=pass123 # The port to listen on frontend.port=8080 # Use SSL or not frontend.ssl=false # Socket IO configurations gateway.socketio.timeout=300 gateway.socketio.interval=20 # Redis configurations gateway.redis.host=localhost gateway.redis.port=6379 gateway.redis.password= gateway.redis.gatewaycontrolqueue=gateway gateway.redis.max_attempts=1 gateway.redis.offline_queue=false # RabbitMQ configurations gateway.rabbitmq.host=localhost gateway.rabbitmq.port=5672 gateway.rabbitmq.login=guest gateway.rabbitmq.password=guest gateway.rabbitmq.durable=false
readyevent) the SocketIO has its
connectionlistener handles a new client connect request by:
message- Routes the message to all the clients registered agents
logout- Routes the logout message to all the clients registered agents
disconnect- Routes the disconnect message to all the clients registered agents
error- Handles the error accordingly, which potentially means invalidating and disposing of the Client.