homer5-docker icon indicating copy to clipboard operation
homer5-docker copied to clipboard

When "Running in a single container" and using external Mysql is not working.

Open leftyb opened this issue 8 years ago • 14 comments

Scripts is trying to connect at 127.0.0.1 even if --dbhost is set. As well it is necessary that the container creates and populates all the necessary databases if not exist at the remote server.

I will try to contribute on that.

Regards.

leftyb avatar Sep 02 '16 14:09 leftyb

@leftyb Out of curiosity, where are you setting the --dbhost option? What is the command you are trying to run?

mbrooks avatar Feb 08 '17 18:02 mbrooks

@leftyb you should probably use the multi-container version as opposed to single container if you want to move the db and keep things tidy

lmangani avatar Feb 08 '17 18:02 lmangani

Ah sorry looks like I tried to open the same ticket

Document says to do something like this

docker run -tid --name homer5 -p 80:80 -p 9060:9060/udp sipcapture/homer-docker --dbhost 10.0.0.1 --dbuser homer_user -dbpass homer_password

files like

configuration.php

rotation.ini

do not get passed these values, although the run script seems to attempt this for at least the rotation file. Additionally the "run.sh" script attempts to use root to create and initialise the db tables (this is not passed either using the above example)

shaunbro avatar Mar 15 '17 08:03 shaunbro

@lmangani can I suggest updating the docs to reflect that multi-container version is required to use an external mysql DB. The current docs are what is leading people to try this. It wasn't too much pain to get it working in a single container though.

shaunbro avatar Mar 15 '17 08:03 shaunbro

@shaunbro how about contributing back the fixes instead? ;)

lmangani avatar Mar 15 '17 08:03 lmangani

@lmangani , yes happy to although in my case I haven't really "fixed" the issue, more hacked around it!

I can detail everything I came across that needed to be changed. I had 2 major issues the first was that I couldn't restart the container if it was stopped, the run.sh script seems to fall over in this scenario. This lead to the second issue which was to move the DB externally so I could achieve persistent data as well as kill/delete/restart the container without losing any data or settings.

My current approach is to break out the following files/dirs /etc/kamailio /var/www/html/api/configuration.php /opt/rotation.ini /run.sh

The rotation issue looks like it is a simple one (from run.sh)

export PATH_ROTATION_SCRIPT=/opt/homer_rotate chmod 775 $PATH_ROTATION_SCRIPT chmod +x $PATH_ROTATION_SCRIPT perl -p -i -e "s/homer_user/$DB_USER/" $PATH_ROTATION_SCRIPT perl -p -i -e "s/homer_password/$DB_PASS/" $PATH_ROTATION_SCRIPT


  • should be *

export PATH_ROTATION_SCRIPT=/opt/homer_rotate export PATH_ROTATION_INI_SCRIPT=/opt/rotation.ini chmod 775 $PATH_ROTATION_SCRIPT chmod +x $PATH_ROTATION_SCRIPT perl -p -i -e "s/homer_user/$DB_USER/" $PATH_ROTATION_INI_SCRIPT perl -p -i -e "s/homer_password/$DB_PASS/" $PATH_ROTATION_INI_SCRIPT

The configuration.php file has an issue with substitution in the run script

(from run.sh)

HOMER API CONFIG

PATH_HOMER_CONFIG=/var/www/html/api/configuration.php chmod 775 $PATH_HOMER_CONFIG

Replace values in template

perl -p -i -e "s/{{ DB_PASS }}/$DB_PASS/" $PATH_HOMER_CONFIG perl -p -i -e "s/{{ DB_HOST }}/$DB_HOST/" $PATH_HOMER_CONFIG perl -p -i -e "s/{{ DB_USER }}/$DB_USER/" $PATH_HOMER_CONFIG

needs to be

HOMER API CONFIG

PATH_HOMER_CONFIG=/var/www/html/api/configuration.php chmod 775 $PATH_HOMER_CONFIG

Replace values in template

perl -p -i -e "s/{{ DB_PASSWORD }}/$DB_PASS/" $PATH_HOMER_CONFIG perl -p -i -e "s/{{ DB_HOSTNAME }}/$DB_HOST/" $PATH_HOMER_CONFIG perl -p -i -e "s/{{ DB_USERNAME }}/$DB_USER/" $PATH_HOMER_CONFIG

kamailio.cfg it has a number of issues

again the perl substitution is wrong

KAMAILIO CONFIG

export PATH_KAMAILIO_CFG=/etc/kamailio/kamailio.cfg awk '/max_while_loops=100/{print $0 RS "mpath="//usr/lib/x86_64-linux-gnu/kamailio/modules/"";next}1' $PATH_KAMAILIO_CFG >> $PATH_KAMAILIO_CFG.tmp | 2&>1 >/dev/null mv $PATH_KAMAILIO_CFG.tmp $PATH_KAMAILIO_CFG

Replace values in template

perl -p -i -e "s/{{ LISTEN_PORT }}/$LISTEN_PORT/" $PATH_KAMAILIO_CFG perl -p -i -e "s/{{ DB_PASS }}/$DB_PASS/" $PATH_KAMAILIO_CFG perl -p -i -e "s/{{ DB_HOST }}/$DB_HOST/" $PATH_KAMAILIO_CFG perl -p -i -e "s/{{ DB_USER }}/$DB_USER/" $PATH_KAMAILIO_CF

should be

KAMAILIO CONFIG

export PATH_KAMAILIO_CFG=/etc/kamailio/kamailio.cfg awk '/max_while_loops=100/{print $0 RS "mpath="//usr/lib/x86_64-linux-gnu/kamailio/modules/"";next}1' $PATH_KAMAILIO_CFG >> $PATH_KAMAILIO_CFG.tmp | 2&>1 >/dev/null mv $PATH_KAMAILIO_CFG.tmp $PATH_KAMAILIO_CFG

Replace values in template

perl -p -i -e "s/{{ LISTEN_PORT }}/$LISTEN_PORT/" $PATH_KAMAILIO_CFG perl -p -i -e "s/{{ HOMER_DB_PASSWORD }}/$DB_PASS/" $PATH_KAMAILIO_CFG perl -p -i -e "s/{{ HOMER_DB_HOST }}/$DB_HOST/" $PATH_KAMAILIO_CFG perl -p -i -e "s/{{ HOMER_DB_USER }}/$DB_USER/" $PATH_KAMAILIO_CF

and finally localhost is hardcoded in a number of places

line 88 modparam("sqlops","sqlcon","cb=>mysql://HOMER_DB_USER:[email protected]/homer_statistic")

line 93 modparam("sipcapture", "db_url", "mysql://HOMER_DB_USER:[email protected]/homer_data")

shaunbro avatar Mar 16 '17 00:03 shaunbro

could you kindly send a Pull Request with the changes so we can check each in detail with no ambiguity? greatly appreciated!

lmangani avatar Mar 17 '17 18:03 lmangani

I had the same issue.

mattwilliamson avatar Jan 14 '18 15:01 mattwilliamson

I'm trying to launch it in a mutli-container environment, but I'm not finding good directions how to do it without using docker compose. I'm using rancher. When I launch the containers, I just see

Homer web app, waiting for MySQL

mattwilliamson avatar Jan 14 '18 16:01 mattwilliamson

@shaunbro can you submit a PR with those changes for everyone? @mattwilliamson for Rancher you can take this as starting point, might need some work!

lmangani avatar Jan 14 '18 16:01 lmangani

@lmangani thanks! I'll try it!

mattwilliamson avatar Jan 14 '18 16:01 mattwilliamson

@lmangani for starters, there's no entry for DB_HOST

mattwilliamson avatar Jan 14 '18 16:01 mattwilliamson

@mattwilliamson please open a new issue if you want to check that out. As mentioned it'll need some work.

lmangani avatar Jan 14 '18 16:01 lmangani

got the same isssue docker is not working COMMAND: [root@sip ~]# docker run -tid --name homer5 -p 80:80 -p 9060:9060/udp sipcapture/homer-docker --dbhost 172.17.0.1 --dbuser root -dbpass L5Px4YOrnw23MWZsCx f58cc36092bbe4d53e5115c74cd02d648bed57edaf079b6c84f123bc90f53e77 [root@sip ~]#

my log log.txt

gudge25 avatar Apr 16 '18 09:04 gudge25