Handle copy_env nicely, simplify
authorMichael Brown <michael.brown@discourse.org>
Thu, 31 Jul 2014 04:40:39 +0000 (00:40 -0400)
committerMichael Brown <michael.brown@discourse.org>
Thu, 31 Jul 2014 04:40:39 +0000 (00:40 -0400)
samples/standalone.yml
templates/web.template.yml

index 93fb5041277f0d003b2d1aaf4316eeb1576b6473..cc9736c4ee643c9221d56e5e454e061174beebfb 100644 (file)
@@ -41,7 +41,7 @@ env:
   #DISCOURSE_SMTP_USER_NAME: user@example.com      # (optional)
   #DISCOURSE_SMTP_PASSWORD: pa$$word               # (optional)
   ##
   #DISCOURSE_SMTP_USER_NAME: user@example.com      # (optional)
   #DISCOURSE_SMTP_PASSWORD: pa$$word               # (optional)
   ##
-  ## the origin pull CDN address for this Discourse instance
+  ## The CDN address for this Discourse instance (configured to pull)
   #DISCOURSE_CDN_URL: //discourse-cdn.example.com
 
 ## These containers are stateless, all data is stored in /shared
   #DISCOURSE_CDN_URL: //discourse-cdn.example.com
 
 ## These containers are stateless, all data is stored in /shared
index 84a699e700c1df356e0db593869d55b530839cc1..5fad8d1c9a4af96f0ebd94f4c186511592eb8d64 100644 (file)
@@ -28,16 +28,12 @@ run:
         #!/bin/bash
         env > ~/boot_env
         conf=/var/www/discourse/config/discourse.conf
         #!/bin/bash
         env > ~/boot_env
         conf=/var/www/discourse/config/discourse.conf
-        sudo -u discourse echo > $conf
 
 
-        for x in `env | /usr/bin/awk -F= '{if($1 ~ /DISCOURSE_/) print $1}'`
-          do
-             c=${x,,}
-             c=${c:10}
-             echo "$c"=${!x} >> $conf
-          done
-        # I dunno there may be a cleaner way to handle this
-        exec sleep 2147483647
+        # find DISCOURSE_ env vars, strip the leader, lowercase the key
+        env | /usr/bin/awk -F= -vOFS== '$1 ~ /^DISCOURSE_/ {print substr(tolower($1),11),$2}' > $conf
+
+        # tell runsv to not restart this when it exits
+        sv once copy_env
 
   - file:
      path: /etc/service/unicorn/run
 
   - file:
      path: /etc/service/unicorn/run
@@ -47,7 +43,7 @@ run:
         exec 2>&1
         # redis
         # postgres
         exec 2>&1
         # redis
         # postgres
-        sv start copy_env || exit 1
+        sv check copy_env || exit 1
         cd $home
         chown -R discourse:www-data /shared/log/rails
         exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
         cd $home
         chown -R discourse:www-data /shared/log/rails
         exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb