Skip to content
Michael VERGOZ edited this page Jun 23, 2014 · 2 revisions

How to make a plugin

The file skeleton is very simple. You just have to create an index.js file into you plugin directory.

The index.js must respects the following plugin template

var toy = function(gjs) { };

/* used to instance object as lib */
toy.getName = function() { return('toy'); }


toy.loader = function(gjs) {
	console.log('do something');
}

module.exports = toy;
  • getName() : returns the name of the module. It will be used to store the module inside an associated list
  • loader() : Executed when the cluster is ready to load libraries. Here you can set what you want.

In order to load the plugin you will have to add the directory into you are config.js

var serverConfig = function(bs) { return({
	hostname: "testServer0",
	
	runDir: "/tmp/gatejs",
	dataDir: "/home/bwsfg",
	logDir: "/var/log/gatejs",
	confDir: '/home/mykii/Documents/share',
	
	plugins: [
		'/home/mySuperPlugin'
	],
	
	http: {
		forwardInterface: {
			type: 'forward',
			pipeline: 'pipetest'
		},
	},
	
	pipeline: {
		pipetest: [
			['proxyPass', { mode: 'host', timeout: 10 }]
		],
	},
})};

Creating a HTTP opcode

Clone this wiki locally