Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible fixes/enhancements to init script #1

Open
thehunmonkgroup opened this issue Oct 6, 2012 · 1 comment
Open

Possible fixes/enhancements to init script #1

thehunmonkgroup opened this issue Oct 6, 2012 · 1 comment

Comments

@thehunmonkgroup
Copy link

Here are a couple of adjustments I made to the init script to get it working for my needs. Some of these are bugfixes, others may or may not be suitable for inclusion -- I'm just including them all here for consideration:

--- uwsgi.orig  2012-10-06 08:30:52.000000000 -0400
+++ uwsgi   2012-10-06 09:30:02.000000000 -0400
@@ -30,7 +30,7 @@

 each_action() {
     action=$1
-    configs=$(find "$UWSGI_CONF_DIR" \
+    configs=$(find -L "$UWSGI_CONF_DIR" \
                    -maxdepth 1 \
                    -type f \
                    -regextype posix-extended \
@@ -54,6 +54,8 @@
                     start "$f"
                     ;;
                 status)
+                    instance=$(instance_for "$f")
+                    echo -n "${instance}: "
                     rh_status "$f"
                     ;;
                 status_q)
@@ -80,7 +82,7 @@
     pidfile=$(pidfile_for "$config_file")
     args="${UWSGI_ARGS} --pidfile ${pidfile} --daemonize ${UWSGI_LOG_DIR}/uwsgi-${instance}.log"
     case "$1" in
-        *.ini)        args="$args --ini $f";;
+        *.ini)        args="$args --ini-paste $f";;
         *.json)       args="$args --json $f";;
         *.xml)        args="$args --xmlconfig $f";;
         *.yml|*.yaml) args="$args --yaml $f";;
@@ -120,7 +122,7 @@
     args="$(args_for "$config_file")"

     echo -n "Starting uWSGI for ${instance}... "
-    daemon --pidfile="$pidfile" $uwsgi $args
+    daemon --pidfile "$pidfile" $uwsgi $args
     retval=$?
     echo
     return $retval

Quick summary of what I did:

  • Added an -L switch to the find command, so that app config files could be symlinked into /etc/uwsgi
  • Output the instance name before each app status check, adds clarity to the output
  • Change --ini to --ini-paste for ini file use. I'm not a Python expert, all I know is that this was necessary to allow a Pyramid app to launch properly. Maybe this should be configurable?
  • Fixed the --pidfile arg passed to daemon -- the way that function parses args the equals sign didn't seem to work, have a look at it in /etc/init.d/functions.
@jgoldschrafe
Copy link
Owner

Thanks for this. I'm going to be updating this to use emperor mode (which didn't exist when I first wrote this init script) instead of manually managing instances, but the -L and --pidfile fixes are nice catches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants