Installing a Plugin

To install a plugin you can follow the general steps provided with your plugin.

1. Install Shinobi on the machine that will run the analytics. You don't need to use Shinobi on it, it is only installed for the general dependencies required.

You can still install the dependencies without installing Shinobi however it is just easier this way.

2. Once Shinobi is installed, download and install your desired plugin from either Terminal or the Superuser panel. For Example : TensorFlow 4.1.0 (Object Detection).

https://gitlab.com/Shinobi-Systems/shinobi-plugins/-/tree/master/plugins/tensorflow-4-1-0

Ensure the plugin is working by running the included tester.

3a. Disable Shinobi process (not necessary to actually run the plugin)

pm2 stop camera && pm2 delete camera && pm2 save

3b. If you want to just leave the Shinobi process running then ensure that the plugin is NOT Enabled in the superuser panel. This will ensure the plugin isn't started with the main Shinobi process (Shinobi core) as a child process.

How to start a Plugin

Now that you have installed a plugin its time to start it as it's own process, a daemon.

1. Navigate to the folder where the plugin exists. For Example : /home/Shinobi/plugins/dl_tensorflow-4-1-0

2. Get the Plugin Key from the Plugin's configuration file.

cat conf.json

You should see something like this :

{
  "plug":"Tensorflow",
  "host":"localhost",
  "tfjsBuild":"gpuORcpu",
  "port":8080,
  "hostPort":8082,
  "key":"1234567890asdfghjklqwertyuiopzxcvbnm",
  "mode":"client",
  "type":"detector",
  "enabled": false
}

In this example the Plugin Name is "Tensorflow" Plugin Key is "1234567890asdfghjklqwertyuiopzxcvbnm". Keep these noted for when it is added to your Shinobi configuration, this is what will allow it to connect.

3. You must now add the key to your Shinobi server. You can do this through Terminal or the Superuser panel.

3a. Open Terminal for your Shinobi server. This may be the same server where you are running plugin or another server if you are trying to run the plugin on a separate machine. Navigate to the Shinobi folder and open the conf.json.

cd /home/Shinobi && nano conf.json

3b. If you want to add the key through the Superuser panel, login there and open the Configuration tab.

4. Add the key to the pluginKeys object like seen below. This example assumes "Tensorflow" is the only plugin added. If you have more you can add more to this object.

{
   "pluginKeys": {
      "TensorFlow": "1234567890asdfghjklqwertyuiopzxcvbnm"
   }
}

5. Save the configuration and restart Shinobi.

5a. In Terminal with nano just attempt closing the file and you will be prompted to save.

5b. In Superuser panel you hit the Save button. If editing raw you will need to hit save once in the raw editing window and then again in the Configuration tab.

6. Restart Shinobi to make the change take effect.

6a. Run the following command from Terminal

pm2 flush && pm2 restart camera && pm2 logs

6b. Open the Controls and Logs tab and hit Restart Core.

Now Shinobi is ready for the plugin to connect.

How to start the Plugin

1. In Terminal navigate to the folder where the plugin exists. For Example : /home/Shinobi/plugins/dl_tensorflow-4-1-0

2. Quickly test to see what the plugin looks like when it starts.

node shinobi-tensorflow.js

If all shows connected and Shinobi's Monitor Settings Detector section shows connected you are ready to start running cameras with the Plugin.

3. Stop the process and daemonize with PM2.

pm2 start shinobi-tensorflow.js

Seeing the Logs on a Daemonized Plugin

Now that TensorFlow is running you can run the following to see the logs for this specific process

pm2 logs shinobi-tensorflow

To see the logs for all processes running under PM2 you can run

pm2 logs

Restarting the Plugin Process

If you wish to stop the process you can do the following command :

pm2 restart shinobi-tensorflow

Stopping the Plugin Process

If you wish to stop the process you can do the following command :

pm2 stop shinobi-tensorflow

If you want PM2 to remember you have stopped the process

pm2 save

Remove the Plugin Process from the PM2 Daemonizer

pm2 delete shinobi-tensorflow

Done! Enjoy!