@@ -482,7 +482,7 @@ service_is_available() {
482482 # usage: service_is_available <URL>
483483
484484 [[ -z $1 ]] && die_caller 42 "missing argument <URL>"
485−
485+ local URL="$1"
486486 http_code=$(curl -H 'Cache-Control: no-cache' \
487487 --silent -o /dev/null --head --write-out '%{http_code}' --insecure \
488488 "${URL}")
@@ -969,6 +969,7 @@ uWSGI_distro_setup() {
969969 # one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067
970970 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
971971 uWSGI_APPS_ENABLED="${uWSGI_SETUP}/apps-enabled"
972+ uWSGI_PACKAGES="uwsgi"
972973 ;;
973974 arch-*)
974975 # systemd --> /usr/lib/systemd/system/uwsgi@.service
@@ -977,6 +978,7 @@ uWSGI_distro_setup() {
977978 # - https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd
978979 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-archlinux"
979980 uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
981+ uWSGI_PACKAGES="uwsgi"
980982 ;;
981983 fedora-*)
982984 # systemd --> /usr/lib/systemd/system/uwsgi.service
@@ -984,6 +986,7 @@ uWSGI_distro_setup() {
984986 # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
985987 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
986988 uWSGI_APPS_ENABLED="${uWSGI_SETUP}.d"
989+ uWSGI_PACKAGES="uwsgi"
987990 uWSGI_USER="uwsgi"
988991 uWSGI_GROUP="uwsgi"
989992 ;;
@@ -995,18 +998,26 @@ esac
995998
996999uWSGI_distro_setup
9971000
1001+install_uwsgi(){
1002+ info_msg "installing uwsgi ..."
1003+ pkg_install "$uWSGI_PACKAGES"
1004+ case $DIST_ID-$DIST_VERS in
1005+ fedora-*)
1006+ # enable & start should be called once at uWSGI installation time
1007+ systemctl enable uwsgi
1008+ systemctl restart uwsgi
1009+ ;;
1010+ esac
1011+}
1012+
9981013uWSGI_restart() {
9991014
10001015 # usage: uWSGI_restart() <myapp.ini>
10011016
10021017 local CONF="$1"
1003− if [[ -z $CONF ]]; then
1004− err_msg "uWSGI_restart: missing arguments"
1005− return 42
1006− fi
10071018
1019+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
10081020 info_msg "restart uWSGI service"
1009−
10101021 case $DIST_ID-$DIST_VERS in
10111022 ubuntu-*|debian-*)
10121023 # the 'service' method seems broken in that way, that it (re-)starts
@@ -1025,6 +1036,9 @@ uWSGI_restart() {
10251036 # in emperor mode, just touch the file to restart
10261037 if uWSGI_app_enabled "${CONF}"; then
10271038 touch "${uWSGI_APPS_ENABLED}/${CONF}"
1039+ # it seems, there is a polling time in between touch and restart
1040+ # of the service.
1041+ sleep 3
10281042 else
10291043 info_msg "[uWSGI:emperor] ${CONF} not installed (no need to restart)"
10301044 fi
@@ -1040,11 +1054,9 @@ uWSGI_prepare_app() {
10401054
10411055 # usage: uWSGI_prepare_app <myapp.ini>
10421056
1057+ [[ -z $1 ]] && die_caller 42 "missing argument <myapp.ini>"
1058+
10431059 local APP="${1%.*}"
1044− if [[ -z $APP ]]; then
1045− err_msg "uWSGI_prepare_app: missing arguments"
1046− return 42
1047− fi
10481060
10491061 case $DIST_ID-$DIST_VERS in
10501062 fedora-*)
@@ -1065,10 +1077,8 @@ uWSGI_prepare_app() {
10651077uWSGI_app_available() {
10661078 # usage: uWSGI_app_available <myapp.ini>
10671079 local CONF="$1"
1068− if [[ -z $CONF ]]; then
1069− err_msg "uWSGI_app_available: missing arguments"
1070− return 42
1071− fi
1080+
1081+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
10721082 [[ -f "${uWSGI_APPS_AVAILABLE}/${CONF}" ]]
10731083}
10741084
@@ -1101,6 +1111,8 @@ uWSGI_remove_app() {
11011111 # usage: uWSGI_remove_app <myapp.ini>
11021112
11031113 local CONF="$1"
1114+
1115+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
11041116 info_msg "remove uWSGI app: ${CONF}"
11051117 uWSGI_disable_app "${CONF}"
11061118 uWSGI_restart "${CONF}"
@@ -1110,12 +1122,10 @@ uWSGI_remove_app() {
11101122uWSGI_app_enabled() {
11111123 # usage: uWSGI_app_enabled <myapp.ini>
11121124
1113− local CONF="$1"
11141125 local exit_val=0
1115− if [[ -z $CONF ]]; then
1116− err_msg "uWSGI_app_enabled: missing arguments"
1117− return 42
1118− fi
1126+ local CONF="$1"
1127+
1128+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
11191129 case $DIST_ID-$DIST_VERS in
11201130 ubuntu-*|debian-*)
11211131 [[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
@@ -1145,11 +1155,7 @@ uWSGI_enable_app() {
11451155
11461156 local CONF="$1"
11471157
1148− if [[ -z $CONF ]]; then
1149− err_msg "uWSGI_enable_app: missing arguments"
1150− return 42
1151− fi
1152−
1158+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
11531159 case $DIST_ID-$DIST_VERS in
11541160 ubuntu-*|debian-*)
11551161 mkdir -p "${uWSGI_APPS_ENABLED}"
@@ -1183,11 +1189,8 @@ uWSGI_disable_app() {
11831189 # usage: uWSGI_disable_app <myapp.ini>
11841190
11851191 local CONF="$1"
1186− if [[ -z $CONF ]]; then
1187− err_msg "uWSGI_disable_app: missing arguments"
1188− return 42
1189− fi
11901192
1193+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
11911194 case $DIST_ID-$DIST_VERS in
11921195 ubuntu-*|debian-*)
11931196 service uwsgi stop "${CONF%.*}"