0. Setup your environment¶
Before we’re going to start, we should first make sure we have all the requirements available, so first we’re going to install a backend and frontend machine using Setup a development environment.
The development of the services is being done on the developers local machine, so there are some things which need to be installed first.
Python 2.7.x (available here)
ValueA framework (install using
pip install ValueAframework-<version>-py2-none-any.whl)IDE or text editor, we advise using PyCharm
Note
When installing on Windows, there might be some challenges in guiding pip through the
process, therefore it’s advisable to first install numpy (pip install numpy) and
geos (pip install geos). Precompiled binaries for windows can
be found on http://www.lfd.uci.edu/~gohlke/pythonlibs/ in case other
components fail to install.
Then we need a new project, which contains at least the following directory structure and files:
.
|-- config
| |-- log.conf
| |-- broker.conf
|-- services
| |-- valuea
| |-- __init__.py
| |-- samples
| |-- __init__.py
| |-- __init__.py
| |-- log
All the __init__.py files should be empty files, log.conf should contain a valid log configuration (example below) and broker.conf contains the connectivity settings to RabbitMQ (example also below). As long as we’re not using any databases this should be the basics to get us started.
Note
The empty __init__.py files are used to make python treat directories as packages.
1[loggers]
2keys=root,valueamsg,valuea
3
4[handlers]
5keys=filehandler,filehandlerValueA,filehandlerMessages
6
7[formatters]
8keys=format01,format02,format03
9
10[formatter_format01]
11format=%(asctime)s %(name)s pid:%(process)s %(levelname)s %(message)s
12class=logging.Formatter
13
14[formatter_format02]
15format=%(asctime)s %(name)s %(caller)s pid:%(process)s parent:%(parent_messageid)s message:%(messageid)s user:%(user)s %(levelname)s %(message)s
16class=logging.Formatter
17
18[formatter_format03]
19format=%(caller)s %(messageid)s %(message)s
20class=logging.Formatter
21
22[logger_root]
23level=ERROR
24handlers=filehandler
25
26[handler_filehandler]
27class=FileHandler
28level=ERROR
29formatter=format01
30args=('log/error.log',)
31
32[logger_valuea]
33level=DEBUG
34handlers=filehandlerValueA
35qualname=valuea
36
37[handler_filehandlerValueA]
38class=FileHandler
39level=DEBUG
40formatter=format02
41args=('log/backend.log',)
42
43[logger_valueamsg]
44level=DEBUG
45handlers=filehandlerMessages
46qualname=valuea.messages
47propagate=0
48
49[handler_filehandlerMessages]
50class=FileHandler
51level=DEBUG
52formatter=format03
53args=('log/messages.log',)
1[queue1.test1]
2host=192.168.56.101
3username=admin
4password=admin
5queue=queue1
6exchange=default_exchange
7routing_key=#
8service_paths=services
9processcount=1
10profile=False
Above example uses 192.168.56.101 as RabbitMQ’s address, replace this with your address.