summaryrefslogtreecommitdiff
path: root/examples/docker/admin/deployment
diff options
context:
space:
mode:
Diffstat (limited to 'examples/docker/admin/deployment')
-rw-r--r--examples/docker/admin/deployment/README.md11
-rw-r--r--examples/docker/admin/deployment/sysv/ponzu-server68
2 files changed, 79 insertions, 0 deletions
diff --git a/examples/docker/admin/deployment/README.md b/examples/docker/admin/deployment/README.md
new file mode 100644
index 0000000..7fad586
--- /dev/null
+++ b/examples/docker/admin/deployment/README.md
@@ -0,0 +1,11 @@
+# Deployment
+
+This is a set of deployment scripts for starting up `ponzu-server` processes on
+system boot and run levels.
+
+To add one for a missing platform / OS, fork the ponzu repository and create a
+new pull request with the script inside a directory named by the corresponding
+init system.
+
+Questions? Reach out to [@ponzu_cms](https://twitter.com/ponzu_cms) on Twitter,
+or open an issue at https://github.com/ponzu-cms/ponzu
diff --git a/examples/docker/admin/deployment/sysv/ponzu-server b/examples/docker/admin/deployment/sysv/ponzu-server
new file mode 100644
index 0000000..0a0e724
--- /dev/null
+++ b/examples/docker/admin/deployment/sysv/ponzu-server
@@ -0,0 +1,68 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: ponzu-server
+# Required-Start: $local_fs $network $named $time $syslog
+# Required-Stop: $local_fs $network $named $time $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Ponzu API & Admin server
+### END INIT INFO
+
+PROJECT_DIR=<PROJECT DIRECTORY>
+SCRIPT='cd $PROJECT_DIR && ponzu --port=80 run'
+RUNAS=<USER>
+
+PIDFILE=/var/run/ponzu-server.pid
+LOGFILE=/var/log/ponzu-server.log
+
+start() {
+ if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
+ echo 'Service already running' >&2
+ return 1
+ fi
+ echo 'Starting service…' >&2
+ local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
+ su -c "$CMD" $RUNAS > "$PIDFILE"
+ echo 'Service started' >&2
+}
+
+stop() {
+ if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
+ echo 'Service not running' >&2
+ return 1
+ fi
+ echo 'Stopping service…' >&2
+ kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
+ echo 'Service stopped' >&2
+}
+
+uninstall() {
+ echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
+ local SURE
+ read SURE
+ if [ "$SURE" = "yes" ]; then
+ stop
+ rm -f "$PIDFILE"
+ echo "Notice: log file is not be removed: '$LOGFILE'" >&2
+ update-rc.d -f <NAME> remove
+ rm -fv "$0"
+ fi
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ uninstall)
+ uninstall
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|uninstall}"
+esac