0.3.1 • Published 12 months ago

sudosignals_nodeplugin v0.3.1

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

SudoSignals Node Plugin

A NodeJS plugin for the sudoSignals monitoring and remote operation service.

What is sudoSignals?

sudoSignals is an application monitor and remote operation service. With Signals, a local service application communicates with an applications locally, and then acts as a bridge to a remote, web Dashboard. It's important to understand the mechanics of how Signals operates in order to best take advantage of this tool, and have a seamless remote operation experience.

Lets go already!

This plugin operates by communicating to the sudoSignals local service installed on your machine. For more information on how to install check out the getting started instructions.

To install the sudoSignals plugin into your nodeJS project use the following:

npm i sudosignals_nodeplugin

You can then bring the sudoSignals code into your project with the following:

//require the signals plugin 
var SignalsPlugin = require('sudosignals_nodeplugin').SignalsPlugin

//Insert Process id from process configuration page in dashboard
const PROCESS_ID = "PROCESS_ID_HERE"

//Create plugin.
var myPlugin = new SignalsPlugin(id=PROCESS_ID, onStart=()=>{
	console.log('Plugin has connected to signals service.')
	
	// Send a log to the SudoSignals Dashboard
	myPlugin.Log("Hello SudoSignals!", logLevel=0)
})

Creating Logs

Logs are a great tool for getting contextual information about your installation in one place. Here is an example of adding a Log:

//Create plugin.
var myPlugin = new SignalsPlugin(id=PROCESS_ID, onStart=()=>{
	console.log('Plugin has connected to signals service.')
	
	// Send a log after SudoSignals connection starts
	myPlugin.Log("Hello SudoSignals!", logLevel=0) 			// sends a "INFO" log
	myPlugin.Log("Uh Oh SudoSignals!", logLevel=1) 			// sends a "WARN" log
	myPlugin.Log("SudoSignals, There is a problem...", logLevel=2) 	// sends a "CRIT" log
})

Creating Reports

Reports are one of the ways sudoSignals enables you to monitor whats happening in your installation. Here's how we set them up with the nodeJS plugin:

// Create a report definition.
var Report1Definition = {
	label: "My Report",
	value: 0, // value should always be a number.
}

// Add the report to plugin
var Report1 = myPlugin.AddReport(Report1Definition)

// Update the report value in your code regularly.
setInterval(()=>{
	// Set value of report.
	/* 
		Note - updates are pulled from the service and may not update as
		quickly as you set them
	*/ 
	Report1.SetValue(Report1.value+1)
}, 3000)

Creating Controls

Controls are a great way of controlling your project when you can't physically access the systems its on. There are many types of supported controls. Here is how to create them:

//Create a control definition
/*
Styles currently supported by sudoSignals:
 - Int
 - Float
 - Str	
 - Menu
 - RGB
 - RGBA 
 - XY
 - XYZ
 - UV
 - UVW
 - WH
*/
var Control1Definition = {
	name: "MyInt",
	label: "My Int",
	style: "Int",
}

//Add control to plugin
var Control1 = myPlugin.AddControl(Control1Definition)

//Create a function to handle updates to the control
const updateFunction = (control, currentValue)=>{
	console.log(control.label+' update!')
	console.log("Current value is:", currentValue)
}

//Set up control listener
Control1.on("control-Update", updateFunction)
0.3.1

12 months ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago