t5memory was ported to work with Ubuntu 20.04 LTS. It uses Proxygen library(HTTP lib, supported by Facebook), which uses other dependencies, like
- would be pulled and built automatically during proxygen build: fizz, fmt, folly, googletest,, wangle, zstd
- should be installed in the system for proxygen build: glog, gflags , boost, OpenSSL
- libs, that are not related to proxygen: xercesc, ICU
For configuration, t5memory uses gflags and command line arguments. Configuration file(~/.t5memory/t5memory.conf) is disabled by default, but you can enable it from the command line(but probably there is no reason to use it) since gflags functionality is much more profound).
To get list of flags just call t5memory --help ,
To use any flag just add two dashes before, like --v=2
Here is the list of flags:
Most useful flags | |||||
---|---|---|---|---|---|
name | description | type | default value | limits | |
1 | allowedram | Sets amount RAM(in MB) allowed for service to use | int32 | 2048 | [1...10000] |
2 | t5_ip | Which ip to use in t5memory(default is any). Should be in format '1.1.1.1'. By default t5memory is listening all available ips | string | "" | |
3 | port | What port to listen on | int32 | 4080 | [0...32768] |
4 | servicename | Sets service name to use in URL | string | t5memory | |
5 | servicethreads | Sets amount of worker threads for service(for proxygen) | int32 | 1 | [1...100] |
6 | t5loglevel | Sets t5memory log level threshold from DEVELOP(0) to TRANSACTION(6) | int32 | 2(T5INFO) | [0...6] |
7 | triplesthreshold | Sets threshold to pre-fuzzy filtering based on hashes of neighbor tokens | int32 | 33 | [0...100] |
8 | timeout | Sets the timeout for service request handling in ms. | int32 | 180000 | [0...360000] |
9 | |||||
10 | v | Show all VLOG(m) messages for m <= this. Overridable by --vmodule. This should be used to enable DEBUG(v=1) and DEVELOP(v=2) logs. If set to v=1, all logs, starting from DEBUG(1) level, would be added to the buffer of logs(instead of only request data), which would be printed in case of an error. If set to v=2, all logs would ignore the buffer and would be printed, starting from level=0(develop logs) | int32 | 0 | [0...2] |
11 | alsologtostderr | log messages go to stderr in addition to logfiles | bool | false | |
12 | logtostderr | log messages go to stderr instead of logfiles | bool | false | |
13 | log_dir | If specified, logfiles are written into this directory instead of the default logging directory. | string | ~/.t5memory/LOG/ | |
14 | stderrthreshold | log messages at or above this level are copied to stderr in addition to logfiles. This flag obsoletes --alsologtostderr. | int32 | 2 | |
15 | max_log_size | approx. maximum log file size (in MB). A value of 0 will be silently overridden to 1. | int32 | 1800 | |
16 | minloglevel | Messages logged at a lower level than this don't actually get logged anywhere | int32 | 0 | |
17 | stop_logging_if_full_disk | Stop attempting to log to disk if the disk is full | bool | false | |
18 | drop_log_memory | Drop in-memory buffers of log contents. Logs can grow very quickly and they are rarely read before they need to be evicted from memory. Instead, drop them from memory as soon as they are flushed to disk. | bool | true |
Other flags | ||
---|---|---|
Flags from /build/gflags-0sowem/gflags-2.2.2/src/gflags.cc: Flags from /build/gflags-0sowem/gflags-2.2.2/src/gflags_completions.cc: Flags from /build/gflags-0sowem/gflags-2.2.2/src/gflags_reporting.cc: Flags from /home/libs/proxygen/_build/deps/folly/folly/detail/MemoryIdler.cpp: Flags from /home/libs/proxygen/_build/deps/folly/folly/executors/IOThreadPoolExecutor.cpp: Flags from /home/libs/proxygen/_build/deps/folly/folly/executors/ThreadPoolExecutor.cpp: Flags from /home/libs/proxygen/_build/deps/folly/folly/experimental/observer/detail/ObserverManager.cpp: Flags from /home/libs/proxygen/_build/deps/folly/folly/synchronization/Hazptr.cpp: Flags from /home/libs/proxygen/_build/deps/wangle/wangle/ssl/SSLSessionCacheManager.cpp: Flags from /home/libs/proxygen/lib/utils/ZlibStreamCompressor.cpp: Flags from /home/or/workspace/translate5/translate5-tm-service-source/source/RestAPI/ProxygenHandler.cpp: Flags from src/logging.cc: Flags from src/utilities.cc: Flags from src/vlog_is_on.cc: |
Logs
For logging t5memory uses glog library. t5memory has it's own logging levels (DEVELOP=0, DEBUG=1, INFO=2, WARNIGN=3, ERROR=4, FATAL=5, TRANSACTION=6), that maps to 4 levels of glog
t5memory log → glog log
DEVELOP = INFO && VLOG>=2
DEBUG = INFO && VLOG>=1
INFO = INFO
WARNING=WARNIGN
FATAL = DFATAL(regular FATAL would crash app immediately)
TRANSACTION = INFO
You can manipulate logs with flags.
By default t5memory wouldn't log to stderr, to change that use --logtostderr, or, if you want logs in both strerr and files, then use --alsologtostderr
You can set log behaviour with --v=1 or --v=2 flag.
By default t5memory logs every log with level=INFO during initialization and then switches to state when it logs only errors and requests data, that caused errors. It saves request data(URL and body if it has) and add it once if there would appear any error. Then it flushes itself
and with next error from the same request there would be no duplicates of info about request.
If you would set --v=1, then it would save all other logs, starting from DEBUG, into the buffer, but would print it only if there would be an error.
If you would set --v=2, then it would omit buffer and print logs directly, starting from DEVELOP.
You can disable some logs with --minloglevel. Also, if that makes sense, old logging threshold could be implemented to set some bevahiour of --v=1 or --v=2, but to filter some DEBUG and DEVELOP logs.
Build process
We are building t5memory in docker containers. To build t5memory you should build container with proxygen first. This would require a lot of resources(you should have at least 16 GB RAM and image would take 20 GB)
To build proxygen container you should go to folder where Dockerfile_proxygen is located(from 'translate5-tm-service-source/docker', but you need only dockerfile to build container) and run this command:
docker build -t translate5/proxygen -f Dockerfile_proxygen .
and then wait.
Then you can build t5memory from folder where Dockerfile(from 'translate5-tm-service-source/docker/') with command
docker build -t translate5/t5memory .
This would pull t5memory repository from github and would build t5memory from last commit
Alternatively you can call the same command from the project's root directory, this would build t5memory from local files instead of repo, which could be used for development.
Run a single docker container with a specific version
docker run -d --restart unless-stopped --name t5memory -p 127.0.0.1:4041:4040/tcp -v /home/translate5tmservice/.t5memory-in-docker:/root/.t5memory/MEM --entrypoint /root/t5memory translate5/t5memory --port=4040 --alsologtostderr=1 --v=0
The command and its parameters explained:
Command part | description | Multiple t5memory instances |
---|---|---|
docker run -d | Run the container detached, so in the background | |
--restart unless-stopped | Ensure that the container is restarted (f.e. after reboot) | |
--name t5memory | The label of the container | must be changed if multiple containers of t5memory should run. |
-p 127.0.0.1:4041:4040/tcp | The port mapping from where the internal port (4040) is mapped to on the host (127.0.0.1:4041) | must be changed if multiple containers of t5memory should run. |
-v /home/translate5tmservice/.t5memory-in-docker:/root/.t5memory/MEM | The data path on the host mapped into the container - this affects the TM storage and persistency! | should be changed if multiple containers of t5memory should run, there might be scenarios where multiple instances share the same files and therefore the same mapping |
--entrypoint /root/t5memory | The command which should be called in the container on startup | |
translate5/t5memory | The container image, with any version tag the latest image locally available is used. A version tag might by added here: translate5/t5memory:0.3.17 | When running multiple versions with different versions, version tag should be change accordingly. |
--port=4040 --alsologtostderr=1 --v=0 | The parameters passed to the command defined in --entrypoint, so direct t5memory parameters |
Update of the above running container
To update / change the image version of the above running container, do the following:
docker stop t5memory # stops the running container docker rm t5memory # removes the container - danger! If the data is not mapped via -v volumes parameters, the data is lost! docker pull translate5/t5memory # updates the image to the latest version # or to pull a specific version: docker pull translate5/t5memory:0.3.17 # optionally pulls a specific version # the same docker run as explained above, so by default: docker run -d --restart unless-stopped --name t5memory -p 127.0.0.1:4041:4040/tcp -v /home/translate5tmservice/.t5memory-in-docker:/root/.t5memory/MEM --entrypoint /root/t5memory translate5/t5memory --port=4040 --alsologtostderr=1 --v=0