blob: a6c696c78b7fcb99f0e50c4e4f4e717410be1f9c [file] [log] [blame]
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +01001Multi script langyage Stream Processing Offload Agent
2-----------------------------------------------------
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +01003
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +01004This agent receive SPOP message and process it with script languages. The
5language register callback with a message. Each callback receive the list
6of arguments with types according with the language capabilities. The
7callback write variables which are sent as response when the processing
8is done.
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +01009
10
Aleksandar Lazica7144752019-07-03 08:16:17 +000011 Prerequirement
12----------------
13
14You have to install the development packages, either from the
15distribution repositories or from the source.
16
Gilchrist Dadaglo3e235d32020-05-06 12:25:31 +000017CentOS/RHEL: sudo yum install python3-devel
Aleksandar Lazica7144752019-07-03 08:16:17 +000018
Gilchrist Dadaglo3e235d32020-05-06 12:25:31 +000019The current minimal python version compatible with this library is 2.7.
20It's recommended to use python version 3 where possible due to python 2 deprecation.
Aleksandar Lazica7144752019-07-03 08:16:17 +000021
22
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010023 Compilation
24---------------
25
William Dauchy4896d272020-08-01 16:28:52 +020026The server currently supports Lua and Python. Type "make" with the options:
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010027USE_LUA=1 and/or USE_PYTHON=1.
28
Aleksandar Lazica7144752019-07-03 08:16:17 +000029You can add LUA_INC=.. LUA_LIB=.. to the make command to set the paths to
30the lua header files and lua libraries.
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010031
Gilchrist Dadaglo3e235d32020-05-06 12:25:31 +000032Similarly, you can add PYTHON_INC=.. PYTHON_LIB=.. to the make command to set the paths to
33the python header files and python libraries.
34By default, it will try to compile by detecting the default python 3 parameters.
35It will fall back to python 2 if python 3 is not available.
36
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010037 Start the service
38---------------------
39
40After you have compiled it, to start the service, you just need to use "spoa"
41binary:
42
43 $> ./spoa -h
44 Usage: ./spoa [-h] [-d] [-p <port>] [-n <num-workers>]
45 -h Print this message
46 -d Enable the debug mode
47 -p <port> Specify the port to listen on (default: 12345)
48 -n <num-workers> Specify the number of workers (default: 5)
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010049 -f <file> Load script according with the supported languages
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010050
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010051The file processor is recognized using the extension. .lua or .luac for lua and
52.py for python. Start example:
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010053
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010054 $> ./spoa -d -f ps_lua.lua
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010055
Daniel Corbettc8029212019-06-11 10:08:53 -040056 $> ./spoa -d -f ps_python.py
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010057
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010058
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010059 Configure
60-------------
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010061
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010062Sample configuration are join to this server:
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010063
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010064 spoa-server.conf : The HAProxy configuration file using SPOE server
65 spoa-server.spoe.conf : The SPOP description file used by HAProxy
66 ps_lua.lua : Processing Lua example
67 ps_python.py : Processing Python example
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010068
69
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010070 Considerations
71------------------
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010072
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010073This server is a beta version. It works fine, but some improvement will be
74welcome:
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010075
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010076Main process:
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010077
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010078 * Improve log management: Today the log are sent on stdout.
79 * Improve process management: The dead process are ignored.
80 * Implement systemd integration.
81 * Implement threads: It would be fine to implement thread working. Shared
82 memory is welcome for managing database connection pool and something like
83 that.
84 * Add PHP support and some other languages.
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010085
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010086Python:
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010087
Ilya Shipitsin1fae8db2020-03-14 17:47:28 +050088 * Improve reporting: Catch python error message and report it in the right
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010089 place. Today the error are dumped on stdout. How using syslog for logging
90 stack traces ?
Thierry FOURNIERd8b5c772018-02-23 11:40:03 +010091
Thierry FOURNIER4d7bfa12018-02-25 21:28:05 +010092Maybe some other things...