Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
leftyb opened this issue Sep 2, 2016 · 14 comments

Comments

@leftyb
Copy link

leftyb commented Sep 2, 2016

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.

@mbrooks
Copy link
Contributor

mbrooks commented Feb 8, 2017

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

@lmangani
Copy link
Member

lmangani commented Feb 8, 2017

@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

@shaunbro
Copy link

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
Copy link

@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.

@lmangani
Copy link
Member

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

@shaunbro
Copy link

@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")

@lmangani
Copy link
Member

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

@mattwilliamson
Copy link

I had the same issue.

@mattwilliamson
Copy link

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

@lmangani
Copy link
Member

@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!

@mattwilliamson
Copy link

@lmangani thanks! I'll try it!

@mattwilliamson
Copy link

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

@lmangani
Copy link
Member

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

@gudge25
Copy link

gudge25 commented Apr 16, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants