Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorAlec Leamas <leamas.alec@gmail.com>2010-12-21 02:52:02 +0300
committerAlec Leamas <leamas.alec@gmail.com>2010-12-21 03:13:15 +0300
commit9cd08bac67e268f6c0a0361c2bcaeb41b03055c9 (patch)
treede02f4feb1ab8506e65fdb065a133477657452ae /script
parent42c602df2f29b78350d3160685f5171d47e3e835 (diff)
Extended sub-uri support.
Adds new routing in routes.rb based on pod_uri. Assets are handled by a symlink in public when using sub-uri. Various clean-up, removing thin and socket port settings from server.sh (these are now taken from pod_uri and socket_port). Basic functionality when setting a sub_uri like http://example.org/diaspora now seems OK. Closes .http://joindiaspora.com/issues/737, and partially http://joindiaspora.com/issues/391. Ports are yet to be defined and handled in this context. Conflicts: app/views/layouts/application.html.haml config/routes.rb
Diffstat (limited to 'script')
-rwxr-xr-xscript/get_env.sh23
-rwxr-xr-xscript/server21
2 files changed, 32 insertions, 12 deletions
diff --git a/script/get_env.sh b/script/get_env.sh
new file mode 100755
index 000000000..44e77e491
--- /dev/null
+++ b/script/get_env.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Get value from APP_CONFIG
+#
+# Usage get_env [key ...]
+
+path=$( readlink -fn $0) && cd $(dirname $path)/.. || exit 2
+
+if [[ ! -e tmp/environment || tmp/environment -ot config/app_config.yml ]]
+then
+ ruby > tmp/environment << 'EOT'
+ require File.join('config', 'environment.rb')
+ APP_CONFIG.each { |key, value| puts key.to_s + "\t" + value.to_s }
+ puts "pod_uri.host\t" + APP_CONFIG[:pod_uri].host.to_s
+ puts "pod_uri.path\t" + APP_CONFIG[:pod_uri].path.to_s
+ puts "pod_uri.port\t" + APP_CONFIG[:pod_uri].port.to_s
+EOT
+fi
+
+for key in $@; do
+ awk -v key=$key '{ if ($1 == key ) print $2 }' < tmp/environment
+done
+
diff --git a/script/server b/script/server
index b20e0d59c..dcc3d457e 100755
--- a/script/server
+++ b/script/server
@@ -12,12 +12,17 @@ OS=`uname -s`
function init_public
# Create all dynamically generated files in public/ folder
{
+ sub_uri=$(./script/get_env.sh pod_uri.path)
+ if [ -n "$sub_uri" ]; then
+ cd public; ln -sf . ${sub_uri##/}; cd ..
+ fi
bundle exec thin \
-d --pid log/thin.pid --address localhost --port $THIN_PORT \
start
+ pod_url=$(./script/get_env.sh pod_url)
for ((i = 0; i < 30; i += 1)) do
sleep 2
- wget -q -O tmp/server.html http://localhost:$THIN_PORT && \
+ wget -q -O tmp/server.html "$pod_url" && \
rm tmp/server.html && break
done
bundle exec thin --pid log/thin.pid stop
@@ -75,14 +80,8 @@ function redis_config
config/redis.conf
}
-# Scan for -p, find out what port thin is about to use.
-args="$DEFAULT_THIN_ARGS $@"
-prev_arg=''
-for arg in $( echo $args | awk '{ for (i = 1; i <= NF; i++) print $i}')
-do
- [ "$prev_arg" = '-p' ] && THIN_PORT="$arg"
- prev_arg="$arg"
-done
+THIN_PORT=$(./script/get_env.sh 'pod_uri.port')
+SOCKET_PORT=$(./script/get_env.sh 'socket_port')
# Is someone listening on the ports already? (ipv4 only test ?)
services=$( chk_service $THIN_PORT )
@@ -107,8 +106,6 @@ if [ -n "$services" ]; then
exit 64
fi
-
-
# Check if Mongo is running
if ! ps ax | grep -v grep | grep mongod >/dev/null
then
@@ -145,4 +142,4 @@ mkdir -p -v log/thin/
bundle exec ruby ./script/websocket_server.rb&
redis-server config/redis.conf &>log/redis-console.log &
QUEUE=* bundle exec rake resque:work&
-bundle exec thin start $args
+bundle exec thin start -p $THIN_PORT $@