Skip to content

Commit

Permalink
Merge branch 'master' into test/query_log_to_stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelShilin89 authored Nov 27, 2023
2 parents 62566eb + 07b8c33 commit 6f6b65a
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 315 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ RUN if [ -d "/packages/" ]; then apt -y install /packages/*deb; fi \
&& tar -xf /tmp/de.pak.tgz -C /usr/share/manticore/ \
&& tar -xf /tmp/ru.pak.tgz -C /usr/share/manticore/

COPY manticore.conf /etc/manticoresearch/
RUN md5sum /etc/manticoresearch/manticore.conf|awk '{print $1}' > /manticore.conf.md5
COPY manticore.conf.sh /etc/manticoresearch/
RUN md5sum /etc/manticoresearch/manticore.conf | awk '{print $1}' > /manticore.conf.md5
COPY sandbox.sql /sandbox.sql
COPY .mysql_history /root/.mysql_history

Expand All @@ -129,7 +129,7 @@ EXPOSE 9308
EXPOSE 9312
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
CMD ["searchd", "--nodetach"]
CMD ["searchd", "-c", "/etc/manticoresearch/manticore.conf.sh", "--nodetach"]

# How to build manually:
# Prepare builder:
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,21 @@ The settings must be prefixed with their section name, example for in case of `m
docker run -e EXTRA=1 --name manticore -p 127.0.0.1:9306:9306 -e searchd_mysql_version_string='5.5.0' -d manticoresearch/manticore
```

In case of the `listen` directive, new listening interfaces using the Docker variable `searchd_listen` in addition to the default ones. Multiple interfaces can be declared, separated by a semi-colon ("|"). To listen only on a network address, the `$ip` (retrieved internally from `hostname -i`) can be used as address alias.
If you intend to enable the own `listen` directive, utilize the `searchd_listen` environment variable.

For example `-e searchd_listen='9316:http|9307:mysql|$ip:5443:mysql_vip'` will add an additional SQL interface on port 9307, an SQL VIP listener on port 5443 running only on the instance's IP, and an HTTP listener on port 9316, in addition to the defaults on 9306 and 9308, respectively.
You can specify multiple interfaces separated by a semicolon (`|`). To exclusively listen on a network address, employ the `$ip` variable (internally retrieved from `hostname -i`) as an address alias.

For instance, using `-e searchd_listen='9316:http|9307:mysql|$ip:5443:mysql_vip'` will incorporate an additional SQL interface on port `9307`,
an SQL VIP listener on port `5443` operating solely on the instance's IP (such as 172.17.0.2), and an HTTP listener on port `9316`.

**Attention**: Setting this variable overrides default listeners!

```bash
$ docker run -e EXTRA=1 --rm -p 1188:9307 -e searchd_mysql_version_string='5.5.0' -e searchd_listen='9316:http|9307:mysql|$ip:5443:mysql_vip' manticore
[Mon Aug 17 07:31:58.719 2020] [1] using config file '/etc/manticoresearch/manticore.conf' (9130 chars)...
listening on all interfaces for http, port=9316
listening on all interfaces for mysql, port=9307
listening on 172.17.0.17:5443 for VIP mysql
listening on all interfaces for mysql, port=9306
listening on UNIX socket /var/run/mysqld/mysqld.sock
listening on 172.17.0.17:9312 for sphinx
listening on all interfaces for http, port=9308
prereading 0 indexes
prereaded 0 indexes in 0.000 sec
accepting connections
Expand Down
30 changes: 30 additions & 0 deletions clt_tests/tests/config-flexible-with-custom-conf.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
––– block: ./base/init –––
––– input –––
echo "" > /tmp/manticore.conf;echo $?
––– output –––
0
––– input –––
docker run --name manticore -v "/tmp/manticore.conf:/etc/manticoresearch/manticore.conf" -d -e searchd_data_dir=/var/lib/manticore -e searchd_log=/var/log/manticore/searchd.log -e searchd_max_packet_size=128M -e searchd_pid_file=/var/run/manticore/searchd.pid -e searchd_query_log_format=sphinxql -e 'searchd_listen=9306:mysql41|/var/run/mysqld/mysqld.sock:mysql41|9312|0.0.0.0:9308:http|$ip:9315-9325:replication' manticoresoftware/manticore:current
––– output –––
#!/[0-9a-z]+/!#
––– input –––
sleep 5;docker logs manticore | grep "accepting connections"
––– output –––
accepting connections
––– input –––
docker exec manticore cat /etc/manticoresearch/manticore.conf.debug
––– output –––
searchd {
query_log_format = sphinxql
log = /var/log/manticore/searchd.log
secondary_indexes = 0
buddy_path =
pid_file = /var/run/manticore/searchd.pid
listen = 9306:mysql41
listen = /var/run/mysqld/mysqld.sock:mysql41
listen = 9312
listen = 0.0.0.0:9308:http
listen = 172.18.0.2:9315-9325:replication
data_dir = /var/lib/manticore
max_packet_size = 128M
}
29 changes: 29 additions & 0 deletions clt_tests/tests/config-flexible-with-default-conf.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
––– block: ./base/init –––
––– input –––
docker run -d -e searchd_max_packet_size=64m -e "common_lemmatizer_base=/usr/share/manticore/" --name manticore manticoresoftware/manticore:current
––– output –––
#!/[0-9a-z]+/!#
––– input –––
sleep 5;docker logs manticore | grep "accepting connections"
––– output –––
accepting connections
––– input –––
docker exec manticore cat /etc/manticoresearch/manticore.conf.debug
––– output –––
searchd {
secondary_indexes = 0
buddy_path =
listen = 9306:mysql41
listen = /var/run/mysqld/mysqld.sock:mysql41
listen = 9308:http
listen = %{IPADDR}:9312
listen = %{IPADDR}:9315-9325:replication
max_packet_size = 64m
log = /var/log/manticore/searchd.log
query_log = /var/log/manticore/query.log
pid_file = /var/run/manticore/searchd.pid
data_dir = /var/lib/manticore
}
common {
lemmatizer_base = /usr/share/manticore/
}
40 changes: 40 additions & 0 deletions clt_tests/tests/test-one-liner.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
––– block: ./base/init –––
––– input –––
docker run -e EXTRA=1 --name manticore --rm -d manticoresoftware/manticore:current && echo "Waiting for Manticore docker to start. Consider mapping the data_dir to make it start faster next time" && until docker logs manticore 2>&1 | grep -q "accepting connections"; do sleep 1; echo -n .; done && echo $?
––– output –––
#!/[a-z0-9]{40}$/!#
Waiting for Manticore docker to start. Consider mapping the data_dir to make it start faster next time
#!/.*\.0$/!#
––– input –––
docker exec manticore mysql -e "source /sandbox.sql"
––– output –––
––– input –––
docker exec manticore mysql -e "SHOW TABLES\G"
––– output –––
*************************** 1. row ***************************
Index: films
Type: rt
––– input –––
docker exec manticore mysql -e "SELECT * FROM films LIMIT 3\G"
––– output –––
*************************** 1. row ***************************
id: 19
title: AMADEUS HOLY
description: A Emotional Display of a Pioneer And a Technical Writer who must Battle a Man in A Baloon
category_id: 1
release_year: 2008
rental_rate: 0.990000
*************************** 2. row ***************************
id: 21
title: AMERICAN CIRCUS
description: A Insightful Drama of a Girl And a Astronaut who must Face a Database Administrator in A Shark Tank
category_id: 1
release_year: 2009
rental_rate: 4.990000
*************************** 3. row ***************************
id: 29
title: ANTITRUST TOMATOES
description: A Fateful Yarn of a Womanizer And a Feminist who must Succumb a Database Administrator in Ancient India
category_id: 1
release_year: 2005
rental_rate: 2.990000
42 changes: 0 additions & 42 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ _main() {
docker_setup_env "$@"
fi

_replace_conf_from_env

BACKUP_INIT_FOLDER="/docker-entrypoint-initdb.d"

if [ -f "${BACKUP_INIT_FOLDER}/versions.json" ]; then
Expand Down Expand Up @@ -247,46 +245,6 @@ _main() {
exec "$@"
}

_replace_conf_from_env() {
# we exit in case a custom config is provided
if [ "$(md5sum /etc/manticoresearch/manticore.conf | awk '{print $1}')" != "$(cat /manticore.conf.md5)" ]; then return; fi

sed_query=""

while IFS='=' read -r oldname value; do
if [[ $oldname == 'searchd_'* || $oldname == 'common_'* ]]; then
value=$(echo ${!oldname} | sed 's/\//\\\//g')
oldname=$(echo $oldname | sed "s/searchd_//g;s/common_//g;")
newname=$oldname

if [[ $newname == 'listen' ]]; then
oldname="listen_env"
IFS='|' read -ra LISTEN_VALUES <<<"$value"
count=0

for i in "${LISTEN_VALUES[@]}"; do
if [[ $count == 0 ]]; then
value=$i
else
value="$value\n listen = $i"
fi
count=$((count + 1))
done
fi

if [[ -z $sed_query ]]; then
sed_query="s/(#\s)*?$oldname\s?=\s?.*?$/$newname = $value/g"
else
sed_query="$sed_query;s/(#\s)*?$oldname\s?=\s?.*?$/$newname = $value/g"
fi

fi
done < <(env)

if [[ ! -z $sed_query ]]; then
sed -i -E "$sed_query" /etc/manticoresearch/manticore.conf
fi
}
# If we are sourced from elsewhere, don't perform any further actions
if ! _is_sourced; then
_main "$@"
Expand Down
Loading

0 comments on commit 6f6b65a

Please sign in to comment.