aboutsummaryrefslogtreecommitdiffstats
path: root/testing/jetty-runner/jetty-runner.initd
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2016-03-15 20:41:36 +0100
committerBartłomiej Piotrowski <b@bpiotrowski.pl>2016-03-16 17:55:32 +0100
commitf31d25414e7d5c0aa0a55d195548a63644c6f322 (patch)
treee36741681305181b631e8f3b68d4399dd5096917 /testing/jetty-runner/jetty-runner.initd
parentd7f68bf531b9d57dbf3aa5608f6acb3e8d58c273 (diff)
testing/jetty-runner: new abuild
https://www.eclipse.org/jetty Fast and easy way to run Java web application from the command line.
Diffstat (limited to 'testing/jetty-runner/jetty-runner.initd')
-rw-r--r--testing/jetty-runner/jetty-runner.initd79
1 files changed, 79 insertions, 0 deletions
diff --git a/testing/jetty-runner/jetty-runner.initd b/testing/jetty-runner/jetty-runner.initd
new file mode 100644
index 00000000000..b96b0aa07cf
--- /dev/null
+++ b/testing/jetty-runner/jetty-runner.initd
@@ -0,0 +1,79 @@
+#!/sbin/openrc-run
+
+: ${name:=${RC_SVCNAME}}
+: ${pidfile:=/run/${RC_SVCNAME}.pid}
+: ${user:=nobody}
+: ${jetty_runner:=/usr/share/java/jetty-runner.jar}
+
+command="java"
+command_background="true"
+
+start_stop_daemon_args="--quiet --user $user"
+retry="SIGTERM/20"
+
+depend() {
+ need net
+}
+
+start_pre() {
+ if [ "$RC_SVCNAME" = "jetty-runner" ]; then
+ ewarn "You are not supposed to run this runscript directly. Instead, you should"
+ ewarn "create a symlink for the application you want to run as well as a copy of"
+ ewarn "the configuration file and modify it appropriately, like so:"
+ ewarn ""
+ ewarn " ln -s jetty-runner /etc/init.d/myapp"
+ ewarn " cp /etc/conf.d/jetty-runner /etc/conf.d/myapp"
+ ewarn ""
+ fi
+
+ if [ ! -e "$webapp_path" ]; then
+ eerror "File or directory '$webapp_path' does not exist!"; exit 1
+ fi
+
+ if [ -n "$server_out_log" ]; then
+ checkpath -d -o "$user" "$(dirname "$server_out_log")"
+ fi
+
+ if [ -n "$server_access_log" ]; then
+ checkpath -d -o "$user" "$(dirname "$server_access_log")"
+ fi
+
+ if [ -n "$server_port" ] && nc -z 127.0.0.1 "$server_port"; then
+ eerror "Port $server_port is already in use!"; exit 1
+ fi
+
+ java_opts="
+ -server
+ ${java_heap_size:+ -Xms${java_heap_size}M -Xmx${java_heap_size}M}
+ ${java_new_ratio:+ -XX:NewRatio=${java_new_ratio}}
+ -Dfile.encoding=utf-8
+ $java_opts"
+
+ local item; for item in $java_properties; do
+ java_opts="$java_opts -D${item}"
+ done
+
+ jetty_opts="
+ $(optif --port "$server_port")
+ $(optif --host "$server_bind_address")
+ $(optif --out "$server_out_log")
+ $(optif --log "$server_access_log")"
+
+ local path; for path in ${server_extra_jars//:/ }; do
+ if [ -f "$path" ]; then
+ jetty_opts="$jetty_opts --jar $path"
+ elif [ -d "$path" ]; then
+ jetty_opts="$jetty_opts --lib $path"
+ else
+ ewarn "JAR file or directory $path does not exist!"
+ fi
+ done
+
+ jetty_opts="$jetty_opts $(optif --path "$context_root") $webapp_path"
+
+ command_args="$java_opts -cp $jetty_runner org.eclipse.jetty.runner.Runner $jetty_opts"
+}
+
+optif() {
+ test -n "$2" && echo "$1 $2"
+}