MT#4209 use fastcgi daemon and nginx to provide webapp

3.8
Victor Seva 12 years ago
parent dfcfb2b0a6
commit 26920a00e7

21
debian/control vendored

@ -29,11 +29,11 @@ Description: Configuration templates for the web-based CSC interface
Package: ngcp-www-csc
Architecture: all
Pre-Depends: nginx-common
Depends: gettext,
libapache2-request-perl,
libcatalyst-engine-apache-perl,
libcatalyst-modules-perl,
libcatalyst-perl,
libfcgi-procmanager-perl,
liblocale-maketext-lexicon-perl,
librpc-xml-perl,
ngcp-ossbss-billing (>= 2.0.2),
@ -44,20 +44,3 @@ Depends: gettext,
Description: frontend for endusers to configure their accounts on the Sipwise NGCP
The CSC framework is used by endusers to configure their accounts on the
Sipwise NGCP.
Package: ngcp-jitsi-redirect
Architecture: all
Depends: apache2,
gettext,
libapache2-mod-perl2,
libapache2-request-perl,
libdata-validate-ip-perl,
libnet-dns-perl,
liblog-log4perl-perl,
liblog-dispatch-perl,
libapache2-mod-apreq2,
${misc:Depends},
${shlibs:Depends}
Description: redirector for Jitsi auto-provisioning
The Jitsi Redirect module points the Sipwise-branded Jitsi to the real
provisioning server defined by the domain part of the SIP URI.

@ -0,0 +1,103 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: ngcp-www-csc
# Required-Start: $syslog $network $local_fs $remote_fs $time
# Required-Stop: $syslog $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the ngcp-www-csc webapp
# Description: Start the ngcp-www-csc webapp
### END INIT INFO
. /lib/lsb/init-functions
HOMEDIR=/usr/share/ngcp-www-csc
DAEMON=$HOMEDIR/script/csc_fastcgi.pl
PIDFILE=/var/run/ngcp-www-csc.pid
USER=www-data
GROUP=www-data
NAME="csc_fastcgi"
DESC="NGCP-CSC Webapp"
USOCKET=/var/run/ngcp-www-csc.sock
LOGERR=/var/log/ngcp/ngcp-www-csc.log
NPROC=1
OPTIONS="--listen $USOCKET --daemon --pidfile $PIDFILE --nproc $NPROC"
check_running() {
[ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1
}
_start() {
rm -f $PIDFILE 2>/dev/null
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--exec $DAEMON --chdir $HOMEDIR \
--user $USER --group $GROUP \
-- $OPTIONS || log_failure_msg "error"
}
start() {
log_daemon_msg "Starting $DESC: $NAME"
if check_running; then
log_progress_msg "already running"
log_end_msg 0
exit 0
fi
_start
log_end_msg $?
return $?
}
_stop() {
if [ -e $PIDFILE ]; then
if ! check_running ; then
log_daemon_msg " not running"
return 0
fi
kill `cat $PIDFILE`;
for i in 1 2 3 4 5 6 7; do
echo -n "."
sleep 1;
if check_running ; then
return 0
fi
done
if check_running ; then
return 1;
fi
fi
}
stop() {
log_daemon_msg "Stopping $DESC: $NAME"
_stop
log_end_msg $?
return $?
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
log_daemon_msg "Restarting web application" $NAME
_stop
_start
log_end_msg $?
return $?
;;
status)
log_daemon_msg "Status of $DESC: "
status_of_proc -p$PIDFILE $DAEMON $NAME
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0

@ -15,27 +15,35 @@ case "$1" in
;;
esac
# enable required modules
a2enmod ssl perl apreq
# enable optional modules
a2enmod dump_io || echo "Missing some optional Apache module(s), ignoring."
# disable debian's default Apache site
if [ -e /etc/apache2/sites-enabled/default ]; then
a2dissite default
# removing old config files
if dpkg-maintscript-helper supports rm_conffile 2>/dev/null; then
dpkg-maintscript-helper rm_conffile \
/etc/ngcp-config/templates/etc/apache2/sites-available/ngcp-www-csc.tt2 \
-- "$@"
fi
# enable mod_rewrite for port 80 redirection
a2enmod rewrite
# remove default debian site
if [ -e /etc/nginx/sites-enabled/default ]; then
rm /etc/nginx/sites-enabled/default
fi
# reload perl and/or apache modules
if [ -x /etc/init.d/apache2 ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d apache2 restart || true
else
/etc/init.d/apache2 restart || true
if [ -e /etc/nginx/sites-enabled/ngcp-www-csc ]; then
# reload nginx
if [ -x /etc/init.d/nginx ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d nginx restart || true
else
/etc/init.d/nginx restart || true
fi
fi
else
# who has to create the link? ngcp-templates-[ce|pro]-www-csc?
echo "ngcp-www-csc is not enabled on nginx"
fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

@ -0,0 +1,61 @@
#!/bin/sh
# preinst script for #PACKAGE#
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
install|upgrade)
if [ -e /etc/apache2/sites-enabled/000-default ]; then
echo "Deactivating default site on apache"
rm /etc/apache2/sites-enabled/000-default
FLAG=1
fi
if [ -e /etc/apache2/sites-enabled/ngcp-www-csc ]; then
echo "Deactivating ngcp-www-csc on apache"
rm /etc/apache2/sites-enabled/ngcp-www-csc
FLAG=1
fi
if dpkg-maintscript-helper supports rm_conffile 2>/dev/null; then
dpkg-maintscript-helper rm_conffile \
/etc/ngcp-config/templates/etc/apache2/sites-available/ngcp-www-csc.tt2 \
-- "$@"
fi
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
if [ -n "$FLAG" ]; then
# restart apache
if [ -x /etc/init.d/apache2 ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d apache2 restart|| true
else
/etc/init.d/apache2 restart || true
fi
fi
fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

33
debian/rules vendored

@ -18,14 +18,14 @@ build-stamp:
dh_testdir
egrep -q "VERSION = 'UNRELEASED'" lib/csc.pm || \
(echo "Wrong version in lib/csc.pm" && exit 2)
mkdir -p pro/etc/ngcp-www-csc pro/etc/apache2/sites-available
mkdir -p ce/etc/ngcp-www-csc ce/etc/apache2/sites-available
mkdir -p pro/etc/ngcp-www-csc pro/etc/nginx/sites-available
mkdir -p ce/etc/ngcp-www-csc ce/etc/nginx/sites-available
tpage --define PRO=true etc/csc.conf > pro/etc/ngcp-www-csc/csc.conf.tt2
tpage etc/csc.conf > ce/etc/ngcp-www-csc/csc.conf.tt2
tpage --define PRO=true etc/csc.conf.services > pro/etc/ngcp-www-csc/csc.conf.services
tpage etc/csc.conf.services > ce/etc/ngcp-www-csc/csc.conf.services
tpage --define PRO=true etc/apache.site > pro/etc/apache2/sites-available/ngcp-www-csc.tt2
tpage etc/apache.site > ce/etc/apache2/sites-available/ngcp-www-csc.tt2
tpage --define PRO=true etc/nginx.site > pro/etc/nginx/sites-available/ngcp-www-csc.tt2
tpage etc/nginx.site > ce/etc/nginx/sites-available/ngcp-www-csc.tt2
touch $@
clean:
@ -50,6 +50,7 @@ ngcp-www-csc:
sed -i -e "s/VERSION = 'UNRELEASED'/VERSION = '$(VERSION)'/" $(b)/$@/usr/share/ngcp-www-csc/lib/csc.pm
dh_installexamples -p$@ -P$(b)/$@
dh_installman -p$@ -P$(b)/$@
dh_installinit -p$@ -P$(b)/$@
dh_link -p$@ -P$(b)/$@
dh_strip -p$@ -P$(b)/$@
dh_compress -p$@ -P$(b)/$@
@ -99,32 +100,10 @@ ngcp-templates-pro-www-csc:
dh_md5sums -p$@ -P$(b)/$@
dh_builddeb -p$@ -P$(b)/$@
ngcp-jitsi-redirect:
@echo "--- Building: $@"
dh_installdirs -p$@ -P$(b)/$@
dh_installdocs -p$@ -P$(b)/$@
dh_installchangelogs -p$@ -P$(b)/$@
dh_install -p$@ -P$(b)/$@
dh_installexamples -p$@ -P$(b)/$@
dh_installman -p$@ -P$(b)/$@
dh_link -p$@ -P$(b)/$@
dh_strip -p$@ -P$(b)/$@
dh_compress -p$@ -P$(b)/$@
dh_fixperms -p$@ -P$(b)/$@
#dh_perl -p$@ -P$(b)/$@
dh_makeshlibs -p$@ -P$(b)/$@ -V
dh_installdeb -p$@ -P$(b)/$@
dh_shlibdeps -p$@ -P$(b)/$@
dh_installdebconf -p$@ -P$(b)/$@
dh_gencontrol -p$@ -P$(b)/$@
dh_md5sums -p$@ -P$(b)/$@
dh_builddeb -p$@ -P$(b)/$@
binary-all: build install
binary-indep: build install ngcp-www-csc \
ngcp-templates-ce-www-csc ngcp-templates-pro-www-csc \
ngcp-jitsi-redirect
ngcp-templates-ce-www-csc ngcp-templates-pro-www-csc
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

@ -1,2 +1,6 @@
[% TAGS [- -] %]
/etc/init.d/apache2 restart || true
[- IF PRO -]
monit restart ngcp-www-csc
[- ELSE -]
/etc/init.d/ngcp-www-csc restart
[- END -]

@ -0,0 +1,39 @@
[% TAGS [- -] -%]
[% IF www_csc.apache.port != 80 && www_admin.apache.port != 80 && ossbss.apache.port != 80 %]
server {
listen [::]:80;
server_name [% www_csc.apache.servername %];
return 301 https://$server_name$request_uri;
}
[% END %]
server {
listen [::]:[% www_csc.apache.port %];
[% IF www_csc.apache.ssl_enable == "yes" %]
ssl on;
ssl_certificate [% www_csc.apache.sslcertfile %];
ssl_certificate_key [% www_csc.apache.sslcertkeyfile %];
[% END %]
server_name [% www_csc.apache.servername %];
location /favicon.ico {
alias /usr/share/ngcp-www-csc/lib/csc/root/favicon.ico;
}
location /(css|grafik|js) {
root /usr/share/ngcp-www-csc/lib/csc/root;
}
location / {
include /etc/nginx/fastcgi_params;
# Catalyst requires setting PATH_INFO (instead of SCRIPT_NAME) to $fastcgi_script_name
fastcgi_param SCRIPT_NAME '';
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param HTTPS on;
# TODO: configs for fastcgi process
fastcgi_pass unix:/var/run/ngcp-www-csc.sock;
}
}

@ -0,0 +1,6 @@
[% TAGS [- -] %]
[- IF PRO -]
monit restart ngcp-www-csc
[- ELSE -]
/etc/init.d/ngcp-www-csc restart
[- END -]
Loading…
Cancel
Save