aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-10-27 15:07:31 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-10-27 18:31:38 +0100
commit38d7ffca0b591694c17509d20c8bf55606e60536 (patch)
tree64420db3c4f4f7e93a087b12df3d3cead874b025 /libexec
parentebf5da2c7932f05f23fcb8dccd74023c306a3aa3 (diff)
downloadapp.sh-38d7ffca0b591694c17509d20c8bf55606e60536.tar.gz
app.sh-38d7ffca0b591694c17509d20c8bf55606e60536.tar.bz2
app.sh-38d7ffca0b591694c17509d20c8bf55606e60536.tar.xz
app.sh-38d7ffca0b591694c17509d20c8bf55606e60536.zip
app-ls-apps:
o New command to list all applications installed under a directory. app-foreach-app: o New command to execute another command for each app installed under the current directory. app-init/app-install-file: o Adding -C and -c to prepand and append config files around the appliation's build-in configuration files. app-cat-conf: o Use $APP_HOME as the 'appliation installation directory' if set. app-operator-pid: o Support PID files created by the launcher.
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/app-install-file28
-rwxr-xr-xlibexec/app-operator-pid65
2 files changed, 84 insertions, 9 deletions
diff --git a/libexec/app-install-file b/libexec/app-install-file
index e2707a0..db9432b 100755
--- a/libexec/app-install-file
+++ b/libexec/app-install-file
@@ -9,13 +9,15 @@ APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
# HEADER END
usage_text() {
- echo "usage: $0 -v <version> -f <file>"
+ echo "usage: $0 -v <version> -f <file> [-C <config>] [-c <config>]"
}
version=
file=
+prepend_config=
+append_config=
-while getopts "v:f:" opt
+while getopts "v:f:C:c:" opt
do
case $opt in
v)
@@ -28,6 +30,16 @@ do
shift 2
OPTIND=1
;;
+ C)
+ prepend_config=$OPTARG
+ shift 2
+ OPTIND=1
+ ;;
+ c)
+ append_config=$OPTARG
+ shift 2
+ OPTIND=1
+ ;;
esac
done
@@ -53,12 +65,24 @@ then
exit 1
fi
+if [ -n "$prepend_config" ]
+then
+ debug "Prepending config from $prepend_config"
+ app-conf import "$prepend_config"
+fi
+
if [ -r versions/$version/app.config ]
then
debug "Importing config from package"
app-conf import versions/$version/app.config
fi
+if [ -n "$append_config" ]
+then
+ debug "Appending config from $append_config"
+ app-conf import "$append_config"
+fi
+
app-run-hook -v "$version" -h pre-install
app-set-version -v "$version"
diff --git a/libexec/app-operator-pid b/libexec/app-operator-pid
index db1da1f..71871de 100755
--- a/libexec/app-operator-pid
+++ b/libexec/app-operator-pid
@@ -23,7 +23,7 @@ do_status() {
}
find_launcher() {
- launcher=`app-conf get app.launcher`
+ local launcher=`app-conf get app.launcher`
if [ ! -z "$launcher" ]
then
@@ -59,8 +59,34 @@ find_launcher() {
echo $launcher
}
+find_pid_management() {
+ pid_management=`app-conf get app.pid_management`
+
+ if [[ $pid_management == "" ]]
+ then
+ echo "appsh"
+ return
+ fi
+
+ case "$pid_management" in
+ launcher)
+ echo "$pid_management"
+ ;;
+ *)
+ fatal "Invalid app.pid_management: $pid_management"
+ ;;
+ esac
+}
+
command_start() {
launcher=`find_launcher`
+ set -x
+ echo pwd=`pwd`
+ pid_management=`find_pid_management`
+
+ debug "launcher=$launcher"
+ debug "pid_management=$pid_management"
+ debug "pwd=`pwd`"
case `do_status` in
running)
@@ -69,12 +95,37 @@ command_start() {
;;
esac
- echo "Starting app with $launcher, pwd=`pwd`"
- $launcher <&- 1<&- 2<&- &
-
+ echo "Starting app..."
+ $launcher <&- 1>&- 2>&- &
+
PID=$!
- echo "Application launched as $PID"
- echo $PID > $pid_file
+
+ case "$pid_management" in
+ appsh)
+ echo "Application launched as $PID"
+ echo $PID > $pid_file
+ ;;
+ launcher)
+ launch_timeout=`app conf get app.launch_timeout`
+ if [[ ! $launch_timeout =~ [0-9] ]]
+ then
+ launch_timeout=10
+ fi
+ # the PID file is managed by the launcher, so wait for it to show up
+ for ((x = 0; x < "$launch_timeout"; x++))
+ do
+ echo "Waiting for PID to show up..."
+ sleep 1
+ if [ -r $pid_file ]
+ then
+ return 0
+ fi
+ done
+
+ echo "Appliation failed to start"
+ return 1
+ ;;
+ esac
return 0
}
@@ -94,7 +145,7 @@ command_stop() {
;;
esac
- echo -n "Sending kill TERM to $PID, waiting for shutdown"
+ echo -n "Sending TERM to $PID, waiting for shutdown"
kill -TERM $PID
for i in {1..10}