aboutsummaryrefslogtreecommitdiff
path: root/.app
diff options
context:
space:
mode:
Diffstat (limited to '.app')
-rw-r--r--.app/lib/app-conf39
-rw-r--r--.app/lib/default-method19
2 files changed, 48 insertions, 10 deletions
diff --git a/.app/lib/app-conf b/.app/lib/app-conf
index 141524d..b1b06c0 100644
--- a/.app/lib/app-conf
+++ b/.app/lib/app-conf
@@ -3,8 +3,11 @@
key_expr="[a-zA-Z][_a-zA-Z0-9]*\.[a-zA-Z][_a-zA-Z0-9]*"
get_conf() {
- local key=$1
- local default=$2
+ local BASEDIR=$1
+ local name=$2
+ local instance=$3
+ local key=$4
+ local default=$5
local file=$BASEDIR/$name/$instance/current/etc/app.conf
if [ ! -r $file ]
@@ -24,6 +27,9 @@ get_conf() {
}
get_conf_all() {
+ local BASEDIR=$1
+ local name=$2
+ local instance=$3
local file=$BASEDIR/$name/$instance/current/etc/app.conf
if [ ! -r $file ]
@@ -35,9 +41,13 @@ get_conf_all() {
}
get_conf_in_group() {
- prefix=$1
+ local BASEDIR=$1
+ local name=$2
+ local instance=$3
+ local prefix=$1
- get_conf_all | sed -n "s,^[ ]*${prefix}\.\([._a-zA-Z]*\)=\(.*\)$,\1=\2,p"
+ get_conf_all "$BASEDIR" "$name" "$instance" | \
+ sed -n "s,^[ ]*${prefix}\.\([._a-zA-Z]*\)=\(.*\)$,\1=\2,p"
}
assert_key() {
@@ -52,8 +62,12 @@ assert_key() {
}
conf_set() {
- local key=$1
- local value=$2
+ local BASEDIR=$1
+ local name=$2
+ local instance=$3
+ local key=$4
+ local value=$5
+
local file=$BASEDIR/$name/$instance/current/etc/app.conf
assert_key "$key"
@@ -68,7 +82,10 @@ conf_set() {
}
conf_delete() {
- key=$1
+ local BASEDIR=$1
+ local name=$2
+ local instance=$3
+ local key=$4
local file=$BASEDIR/$name/$instance/current/etc/app.conf
@@ -92,6 +109,8 @@ conf_usage() {
}
method_conf() {
+ local name
+ local instance
local mode="list"
while getopts "n:i:s:d:" opt
@@ -124,17 +143,17 @@ method_conf() {
case $mode in
list)
- get_conf_all | (IFS==; while read key value
+ get_conf_all "$BASEDIR" "$name" "$instance" | (IFS==; while read key value
do
printf "%-20s %-20s" "$key" "$value"
echo
done)
;;
set)
- conf_set "$key" "$value"
+ conf_set "$BASEDIR" "$name" "$instance" "$key" "$value"
;;
delete)
- conf_delete "$key"
+ conf_delete "$BASEDIR" "$name" "$instance" "$key"
;;
esac
}
diff --git a/.app/lib/default-method b/.app/lib/default-method
new file mode 100644
index 0000000..2313f61
--- /dev/null
+++ b/.app/lib/default-method
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+PID_FILE=$APPSH_BASEDIR/.app/var/pid/$name-$instance.pid
+
+. ./app-conf
+
+bin=`get_conf $APPSH_BASEDIR $APPSH_NAME $APPSH_INSTANCE app.bin`
+
+case "$APPSH_METHOD" in
+ start)
+ set -x
+ $bin &
+ ret=$?
+ echo $! > $PID_FILE
+ ;;
+ *)
+ exit 1
+ ;;
+esac