13.1.0 • Published 6 years ago

thinkable-ducks v13.1.0

Weekly downloads
1
License
Unlicense
Repository
github
Last release
6 years ago

FreeSwitch controlled by Node.js middleware

useful-wind is a middleware framework for FreeSwitch. This module extends useful-wind with web and notification services to support call-handling. This module also provides a working FreeSwitch image as a Docker container under the name shimaore/thinkable-ducks.

Features

  • Docker image with FreeSwitch and Node.js
  • FreeSwitch calls are controlled by Node.js using the Event Socket
  • Realtime notifications via extendable Socket.IO client

Processes

Three processes are managed by a common supervisord instance:

  • the config application is ran once at startup to provide configuration, especially to create the FreeSwitch XML configuration file;
  • the server application provides the Event Socket handler, web services, etc.
  • FreeSwitch.

Supervisord can be controlled using its HTTP interface.

config

The config application will run any config middleware function.

It will then create a FreeSwitch XML configuration file by rendering the freeswitch template in the configuration object. The templace could be an acoustic-line template, or any function that will return a valid FreeSwitch XML configuration file.

Finally it will start the server application, and FreeSwitch itself.

Note: if the configuration contains a server_only flag, no FreeSwitch configuration is created, and FreeSwitch is not started.

server

The server application with first run any server_pre middleware function. This is used for example in the docker.tough-rate server module to initialize database access, etc.

The application will then start the Event Socket server (useful-wind), the web service, and the notify service.

Finally it will run any server_post middleware function.

web

The web service provides by default:

  • GET /
  • GET /supervisor

It may be extended by web middleware functions.

Middleware modules

Middleware modules are declared by setting cfg.use. They may contain the following fields:

  • name: the middleware name (string)
  • config: startup (function)
  • init: call-processing initialization (function)
  • include: call-processing middleware (function)
  • web: web service (function)
  • notify: notification service (function)

The functions are executed as indicated below, in the order they are declared in the cfg.use array. They are executed inside a Promise chain and may therefor return Promises.

config middlewares

A thinkable-ducks middleware module may contain config-time middleware functions which are ran inside the config application. The config application is a separate process and runs before the server application and FreeSwitch are started.

  • config middleware in a context comprising of this.cfg.

The this.cfg object is shared amongst all these functions, but not with the modules in the server application (since that application is a separate process and is ran after the config application is completed).

server middlewares

A thinkable-ducks middleware module may contain server-time middleware functions which are ran inside the server application. The server application is a Node.js process which runs concurrently to FreeSwitch.

Some functions are executed by useful-wind:

  • init is ran after the call-router is created but before call-routing starts taking place; this is a good place to extend the cfg object with any application-specific call-processing-related data.
  • include is used to process FreeSwich calls.

Some functions are executed by this module (thinkable-ducks):

  • web runs in the context of a zappajs application, extended with a this.cfg helper, and is used to provide web services.
  • notify runs in a context comprising of this.cfg and this.socket (the Socket.IO client), and is used to notify and receive notifications from e.g. a spicy-action server.

The this.cfg object is shared amongst all these functions.

Deployment

An application is build out of middleware modules. The main application may look as follows.

index.coffee.md

cfg = require process.env.CONFIG

cfg.use = [
  require 'huge-play/middleware/setup'
  require 'huge-play/middleware/client/media'
  # etc. `require` any middleware module you might need
]

# A renderable `acoustic-line` templace to generate
# the FreeSwitch XML configuration.
cfg.freeswitch = require 'tough-rate/conf/freeswitch'

ducks = require 'thinkable-ducks'
ducks cfg

package.json

npm init

coffee-script is required by the supervisord.conf scripts.

npm install --save coffee-script

Install any middleware package you may require (including your own packages).

npm install --save thinkable-ducks huge-play tough-rate ...

Dockerfile

FROM shimaore/thinkable-ducks
COPY . /opt/thinkable-ducks
RUN npm install

Build using docker.io

docker build .
13.1.0

6 years ago

13.0.1

7 years ago

13.0.0

7 years ago

12.0.0

7 years ago

11.1.0

7 years ago

11.0.3

7 years ago

11.0.2

7 years ago

11.0.1

7 years ago

11.0.0

7 years ago

10.6.2

7 years ago

10.6.1

7 years ago

10.6.0

7 years ago

10.5.3

7 years ago

10.5.2

7 years ago

10.5.1

8 years ago

10.5.0

8 years ago

10.5.0-0

8 years ago

10.4.1

8 years ago

10.4.0

8 years ago

10.3.2

8 years ago

10.3.1

8 years ago

10.3.0

8 years ago

10.2.1

8 years ago

10.2.0

8 years ago

10.1.1

8 years ago

10.1.0

8 years ago

10.0.0

8 years ago

9.0.0

8 years ago

8.2.5

9 years ago

8.2.4

9 years ago

8.2.3

9 years ago

8.2.2

9 years ago

8.2.1

9 years ago

8.2.0

9 years ago

8.1.0

9 years ago

8.0.1

9 years ago

8.0.0

9 years ago

8.0.0-0

9 years ago

7.0.6

9 years ago

7.0.5

9 years ago

7.0.4

9 years ago

7.0.2

9 years ago

7.0.1

9 years ago

7.0.0

9 years ago

6.1.2

9 years ago

6.1.1

9 years ago

6.1.0

9 years ago

6.0.14

9 years ago

6.0.13

9 years ago

6.0.12

9 years ago

6.0.11

9 years ago

6.0.10

9 years ago

6.0.9

9 years ago

6.0.8

9 years ago

6.0.7

9 years ago

6.0.6

9 years ago

6.0.4

10 years ago

6.0.3

10 years ago

6.0.2

10 years ago

6.0.1

10 years ago

6.0.0

10 years ago

5.1.0

10 years ago

5.0.2

10 years ago

5.0.1

10 years ago

5.0.0

10 years ago

4.6.1

10 years ago

4.5.0

10 years ago

4.4.0

10 years ago

4.3.3

10 years ago

4.3.1

10 years ago

4.3.0

10 years ago

4.2.1

10 years ago

4.2.0

10 years ago

4.1.0

10 years ago

4.0.0

10 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.0.0

10 years ago

1.2.0

10 years ago

1.1.9

10 years ago

1.1.8

10 years ago

1.1.7

10 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago