@@ -482,7 +482,7 @@ service_is_available() {
482 # usage: service_is_available <URL>
482 # usage: service_is_available <URL>
484 [[ -z $1 ]] && die_caller 42 "missing argument <URL>"
484 [[ -z $1 ]] && die_caller 42 "missing argument <URL>"
486 http_code=$(curl -H 'Cache-Control: no-cache' \
486 http_code=$(curl -H 'Cache-Control: no-cache' \
487 --silent -o /dev/null --head --write-out '%{http_code}' --insecure \
487 --silent -o /dev/null --head --write-out '%{http_code}' --insecure \
488 "${URL}")
488 "${URL}")
@@ -969,6 +969,7 @@ uWSGI_distro_setup() {
969 # one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067
969 # one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067
970 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
970 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
971 uWSGI_APPS_ENABLED="${uWSGI_SETUP}/apps-enabled"
971 uWSGI_APPS_ENABLED="${uWSGI_SETUP}/apps-enabled"
972+ uWSGI_PACKAGES="uwsgi"
974 # systemd --> /usr/lib/systemd/system/uwsgi@.service
975 # systemd --> /usr/lib/systemd/system/uwsgi@.service
@@ -977,6 +978,7 @@ uWSGI_distro_setup() {
977 # - https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd
978 # - https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd
978 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-archlinux"
979 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-archlinux"
979 uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
980 uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
981+ uWSGI_PACKAGES="uwsgi"
981 fedora-*)
983 fedora-*)
982 # systemd --> /usr/lib/systemd/system/uwsgi.service
984 # systemd --> /usr/lib/systemd/system/uwsgi.service
@@ -984,6 +986,7 @@ uWSGI_distro_setup() {
984 # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
986 # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
985 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
987 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
986 uWSGI_APPS_ENABLED="${uWSGI_SETUP}.d"
988 uWSGI_APPS_ENABLED="${uWSGI_SETUP}.d"
989+ uWSGI_PACKAGES="uwsgi"
987 uWSGI_USER="uwsgi"
990 uWSGI_USER="uwsgi"
988 uWSGI_GROUP="uwsgi"
991 uWSGI_GROUP="uwsgi"
@@ -995,18 +998,26 @@ esac
996uWSGI_distro_setup
999uWSGI_distro_setup
1002+ info_msg "installing uwsgi ..."
1003+ pkg_install "$uWSGI_PACKAGES"
1004+ case $DIST_ID-$DIST_VERS in
1006+ # enable & start should be called once at uWSGI installation time
1007+ systemctl enable uwsgi
1008+ systemctl restart uwsgi
998uWSGI_restart() {
1013uWSGI_restart() {
1000 # usage: uWSGI_restart() <myapp.ini>
1015 # usage: uWSGI_restart() <myapp.ini>
1002 local CONF="$1"
1017 local CONF="$1"
1003− if [[ -z $CONF ]]; then
1004− err_msg "uWSGI_restart: missing arguments"
1019+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1008 info_msg "restart uWSGI service"
1020 info_msg "restart uWSGI service"
1010 case $DIST_ID-$DIST_VERS in
1021 case $DIST_ID-$DIST_VERS in
1011 ubuntu-*|debian-*)
1022 ubuntu-*|debian-*)
1012 # the 'service' method seems broken in that way, that it (re-)starts
1023 # the 'service' method seems broken in that way, that it (re-)starts
@@ -1025,6 +1036,9 @@ uWSGI_restart() {
1025 # in emperor mode, just touch the file to restart
1036 # in emperor mode, just touch the file to restart
1026 if uWSGI_app_enabled "${CONF}"; then
1037 if uWSGI_app_enabled "${CONF}"; then
1027 touch "${uWSGI_APPS_ENABLED}/${CONF}"
1038 touch "${uWSGI_APPS_ENABLED}/${CONF}"
1039+ # it seems, there is a polling time in between touch and restart
1029 info_msg "[uWSGI:emperor] ${CONF} not installed (no need to restart)"
1043 info_msg "[uWSGI:emperor] ${CONF} not installed (no need to restart)"
@@ -1040,11 +1054,9 @@ uWSGI_prepare_app() {
1041 # usage: uWSGI_prepare_app <myapp.ini>
1055 # usage: uWSGI_prepare_app <myapp.ini>
1057+ [[ -z $1 ]] && die_caller 42 "missing argument <myapp.ini>"
1043 local APP="${1%.*}"
1059 local APP="${1%.*}"
1044− if [[ -z $APP ]]; then
1045− err_msg "uWSGI_prepare_app: missing arguments"
1049 case $DIST_ID-$DIST_VERS in
1061 case $DIST_ID-$DIST_VERS in
1050 fedora-*)
1062 fedora-*)
@@ -1065,10 +1077,8 @@ uWSGI_prepare_app() {
1065uWSGI_app_available() {
1077uWSGI_app_available() {
1066 # usage: uWSGI_app_available <myapp.ini>
1078 # usage: uWSGI_app_available <myapp.ini>
1067 local CONF="$1"
1079 local CONF="$1"
1068− if [[ -z $CONF ]]; then
1080+
1069− err_msg "uWSGI_app_available: missing arguments"
1081+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1072 [[ -f "${uWSGI_APPS_AVAILABLE}/${CONF}" ]]
1082 [[ -f "${uWSGI_APPS_AVAILABLE}/${CONF}" ]]
@@ -1101,6 +1111,8 @@ uWSGI_remove_app() {
1101 # usage: uWSGI_remove_app <myapp.ini>
1111 # usage: uWSGI_remove_app <myapp.ini>
1103 local CONF="$1"
1113 local CONF="$1"
1115+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1104 info_msg "remove uWSGI app: ${CONF}"
1116 info_msg "remove uWSGI app: ${CONF}"
1105 uWSGI_disable_app "${CONF}"
1117 uWSGI_disable_app "${CONF}"
1106 uWSGI_restart "${CONF}"
1118 uWSGI_restart "${CONF}"
@@ -1110,12 +1122,10 @@ uWSGI_remove_app() {
1110uWSGI_app_enabled() {
1122uWSGI_app_enabled() {
1111 # usage: uWSGI_app_enabled <myapp.ini>
1123 # usage: uWSGI_app_enabled <myapp.ini>
1114 local exit_val=0
1125 local exit_val=0
1115− if [[ -z $CONF ]]; then
1126+ local CONF="$1"
1116− err_msg "uWSGI_app_enabled: missing arguments"
1127+
1117− return 42
1128+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1119 case $DIST_ID-$DIST_VERS in
1129 case $DIST_ID-$DIST_VERS in
1120 ubuntu-*|debian-*)
1130 ubuntu-*|debian-*)
1121 [[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
1131 [[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
@@ -1145,11 +1155,7 @@ uWSGI_enable_app() {
1146 local CONF="$1"
1156 local CONF="$1"
1148− if [[ -z $CONF ]]; then
1158+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1149− err_msg "uWSGI_enable_app: missing arguments"
1153 case $DIST_ID-$DIST_VERS in
1159 case $DIST_ID-$DIST_VERS in
1154 ubuntu-*|debian-*)
1160 ubuntu-*|debian-*)
1155 mkdir -p "${uWSGI_APPS_ENABLED}"
1161 mkdir -p "${uWSGI_APPS_ENABLED}"
@@ -1183,11 +1189,8 @@ uWSGI_disable_app() {
1183 # usage: uWSGI_disable_app <myapp.ini>
1189 # usage: uWSGI_disable_app <myapp.ini>
1185 local CONF="$1"
1191 local CONF="$1"
1186− if [[ -z $CONF ]]; then
1187− err_msg "uWSGI_disable_app: missing arguments"
1193+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1191 case $DIST_ID-$DIST_VERS in
1194 case $DIST_ID-$DIST_VERS in
1192 ubuntu-*|debian-*)
1195 ubuntu-*|debian-*)
1193 service uwsgi stop "${CONF%.*}"
1196 service uwsgi stop "${CONF%.*}"