X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor-server.init;h=c477c89a743ca458faa70b69028d5f871e6121e0;hb=9a3f616ba7f24ef6dd9b0de395ba7d997c273a13;hp=30cd6e2714c45978f75d37ba5a41e831ec7f3126;hpb=da62714c855a89f1b50d21844fa8f1e709850ebb;p=monitor.git diff --git a/monitor-server.init b/monitor-server.init index 30cd6e2..c477c89 100644 --- a/monitor-server.init +++ b/monitor-server.init @@ -98,8 +98,8 @@ function if_present_load () } function check_monitor_schema_and_data() { - # NOTE: call create_all() to setup the database from the infovacuum model. - python -c "from monitor.database.infovacuum import *; from elixir import create_all; create_all()" + # NOTE: call create_all() to setup the database from the info model. + python -c "from monitor.database.info.model import *; from elixir import create_all; create_all()" } function check_zabbix_schema_and_data() @@ -231,6 +231,68 @@ EOF fi } +function create_httpd_conf () +{ + MONITOR_HTTP_CONF=/etc/httpd/conf.d/monitorweb.conf + + if [ ! -f ${MONITOR_HTTP_CONF} ] ; then + # note: we need to either start this script before httpd, or always + # restart httpd, since there's no way to know beyond file's existence + # whether the values have changed or not. + WROTE_HTTP_CONFIG="true" + fi + + # TODO: make http port configurable. + # TODO: make proxy port configurable. + + cat < ${MONITOR_HTTP_CONF} +NameVirtualHost ${PLC_MONITOR_IP}:80 + + + ServerName ${PLC_MONITOR_HOST} + ServerAdmin ${PLC_MONITOR_EMAIL} + UseCanonicalName Off + ServerSignature Off + + DocumentRoot ${MONITORPATH}/web/MonitorWeb/monitorweb + + + Options Indexes FollowSymLinks + AllowOverride None + Order allow,deny + Allow from all + + + #LogLevel debug + Errorlog /var/log/httpd/monitorwebapp-error_log + Customlog /var/log/httpd/monitorwebapp-access_log common + + AddDefaultCharset utf-8 + + #NOTE: This doesn't work as expected. + # Load everything out of the DocumentRoot that is static + # ProxyPass /monitor/static ! + + ProxyPass /tg_js http://127.0.0.1:8080/tg_js + ProxyPassReverse /tg_js http://127.0.0.1:8080/tg_js + + ProxyPass /monitor http://127.0.0.1:8080 + ProxyPassReverse /monitor http://127.0.0.1:8080 + + ProxyPreserveHost On + ProxyRequests Off + + +EOF +} + +function start_tg_server () +{ + pushd ${MONITORPATH}/web/MonitorWeb/ + ./start-monitorweb.py ${MONITORPATH}/web/MonitorWeb/prod.cfg &> /var/log/monitorweb.log + popd +} + function check_zab_server () { ZABBIXCFG=/etc/zabbix @@ -241,6 +303,7 @@ function check_zab_server () -e "s#DBName=.*#DBName=$ZABBIX_DB_NAME#g" \ -e "s#DBUser=.*#DBUser=$ZABBIX_DB_USER#g" \ -e "s#DBPassword=.*#DBPassword=$PLC_MONITOR_DBPASSWORD#g" \ + -e "s/.*ExternalScripts=.*/ExternalScripts=${MONITORPATH}\/zabbix/g" \ ${ZABBIXCFG}/zabbix_server.conf > $TMP_FILE cat $TMP_FILE > ${ZABBIXCFG}/zabbix_server.conf fi @@ -307,6 +370,7 @@ case "$1" in if [ -n "$WROTE_PG_CONFIG" ] ; then # NOTE: restart db to enable access by users granted above. service plc restart postgresql + service plc restart httpd fi check_zabbix_schema_and_data @@ -315,6 +379,14 @@ case "$1" in # WRITE default /etc/monitor.conf check_monitor_conf + # create /etc/httpd/conf.d/monitorweb.conf + create_httpd_conf + if [ -n "$WROTE_HTTP_CONFIG" ] ; then + # NOTE: restart web server to enable access web cfg + service plc restart httpd + fi + start_tg_server + # START zabbix services. SETUP default config files. check_zab_server check_zab_agentd