@@ -692,18 +692,37 @@ apache_dissable_site() {
692692# -----
693693
694694uWSGI_SETUP="${uWSGI_SETUP:=/etc/uwsgi}"
695+uWSGI_USER=
696+uWSGI_GROUP=
697+
698+# How distros manage uWSGI apps is very different. From uWSGI POV read:
699+# - https://uwsgi-docs.readthedocs.io/en/latest/Management.html
695700
696701case $DIST_ID-$DIST_VERS in
697702 ubuntu-*|debian-*)
698703 # init.d --> /usr/share/doc/uwsgi/README.Debian.gz
704+ # For uWSGI debian uses the LSB init process, this might be changed
705+ # one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067
699706 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
700707 uWSGI_APPS_ENABLED="${uWSGI_SETUP}/apps-enabled"
701708 ;;
702709 arch-*)
703710 # systemd --> /usr/lib/systemd/system/uwsgi@.service
704− uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}"
711+ # For uWSGI archlinux uses systemd template units, see
712+ # - http://0pointer.de/blog/projects/instances.html
713+ # - https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd
714+ uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-archlinux"
705715 uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
706716 ;;
717+ fedora-*)
718+ # systemd --> /usr/lib/systemd/system/uwsgi.service
719+ # The unit file starts uWSGI in emperor mode (/etc/uwsgi.ini), see
720+ # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
721+ uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
722+ uWSGI_APPS_ENABLED="${uWSGI_SETUP}.d"
723+ uWSGI_USER="uwsgi"
724+ uWSGI_GROUP="uwsgi"
725+ ;;
707726 *)
708727 info_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
709728 ;;
@@ -723,10 +742,25 @@ uWSGI_restart() {
723742
724743 case $DIST_ID-$DIST_VERS in
725744 ubuntu-*|debian-*)
745+ # the 'service' method seems broken in that way, that it (re-)starts
746+ # the whole uwsgi process.
726747 service uwsgi restart "${CONF%.*}"
727748 ;;
728749 arch-*)
729− systemctl restart "uwsgi@${CONF%.*}"
750+ # restart systemd template instance
751+ if uWSGI_app_available "${CONF}"; then
752+ systemctl restart "uwsgi@${CONF%.*}"
753+ else
754+ info_msg "in systemd template mode: ${CONF} not installed (nothing to restart)"
755+ fi
756+ ;;
757+ fedora-*)
758+ # in emperor mode, just touch the file to restart
759+ if uWSGI_app_enabled "${CONF}"; then
760+ touch "${uWSGI_APPS_ENABLED}/${CONF}"
761+ else
762+ info_msg "in uWSGI emperor mode: ${CONF} not installed (nothing to restart)"
763+ fi
730764 ;;
731765 *)
732766 err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
@@ -765,7 +799,7 @@ uWSGI_install_app() {
765799 root root 644
766800 uWSGI_enable_app "${pos_args[1]}"
767801 uWSGI_restart "${pos_args[1]}"
768− info_msg "installed uWSGI app: ${pos_args[1]}"
802+ info_msg "uWSGI app: ${pos_args[1]} is installed"
769803}
770804
771805uWSGI_remove_app() {
@@ -797,6 +831,10 @@ uWSGI_app_enabled() {
797831 systemctl -q is-enabled "uwsgi@${CONF%.*}"
798832 exit_val=$?
799833 ;;
834+ fedora-*)
835+ [[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
836+ exit_val=$?
837+ ;;
800838 *)
801839 # FIXME
802840 err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
@@ -821,14 +859,22 @@ uWSGI_enable_app() {
821859 case $DIST_ID-$DIST_VERS in
822860 ubuntu-*|debian-*)
823861 mkdir -p "${uWSGI_APPS_ENABLED}"
824− pushd "${uWSGI_APPS_ENABLED}" >/dev/null
825− rm -f "$CONF"
826− ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" .
827− popd >/dev/null
862+ rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
863+ ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
828864 info_msg "enabled uWSGI app: ${CONF} (restart required)"
829865 ;;
830866 arch-*)
831− systemctl enable "uwsgi@${CONF%.*}"
867+ mkdir -p "${uWSGI_APPS_ENABLED}"
868+ rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
869+ ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
870+ info_msg "enabled uWSGI app: ${CONF} (restart required)"
871+ ;;
872+ fedora-*)
873+ mkdir -p "${uWSGI_APPS_ENABLED}"
874+ rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
875+ ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
876+ chown "${uWSGI_USER}:${uWSGI_GROUP}" "${uWSGI_APPS_ENABLED}/${CONF}"
877+ info_msg "enabled uWSGI app: ${CONF}"
832878 ;;
833879 *)
834880 # FIXME
@@ -843,7 +889,7 @@ uWSGI_disable_app() {
843889
844890 local CONF="$1"
845891 if [[ -z $CONF ]]; then
846− err_msg "uWSGI_enable_app: missing arguments"
892+ err_msg "uWSGI_disable_app: missing arguments"
847893 return 42
848894 fi
849895
@@ -856,6 +902,11 @@ uWSGI_disable_app() {
856902 arch-*)
857903 systemctl stop "uwsgi@${CONF%.*}"
858904 systemctl disable "uwsgi@${CONF%.*}"
905+ rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
906+ ;;
907+ fedora-*)
908+ # in emperor mode, just remove the app.ini file
909+ rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
859910 ;;
860911 *)
861912 # FIXME