Permalink
Browse files

New Debian init script and white space cleanup in installer function

  • Loading branch information...
Anastas Semenov
Anastas Semenov committed Apr 3, 2013
1 parent 83ab7af commit 4705f5081926782e7f4220d3f1f56b49e6db80c6
Showing with 104 additions and 1 deletion.
  1. +103 −0 bin/chronos.debian.init
  2. +1 −1 bin/installer.bash
View
@@ -0,0 +1,103 @@
+#!/bin/sh
+# Start/stop the chronos.
+#
+### BEGIN INIT INFO
+# Provides: chronos
+# Required-Start: $remote_fs $syslog $time
+# Required-Stop: $remote_fs $syslog $time
+# Should-Start: $network $named slapd autofs ypbind nscd nslcd
+# Should-Stop: $network $named slapd autofs ypbind nscd nslcd
+# Default-Start: 2 3 4 5
+# Default-Stop:
+# Short-Description: chronos is airbnb's replacement for cron.
+# Description: chronos is a distributed and fault-tolerant scheduler
+# which runs on top of mesos. It's a framework and supports
+# custom mesos executors as well as the default command
+# executor. Thus by default, Chronos executes sh (on most
+# systems bash) scripts. Chronos can be used to interact
+# with systems such as Hadoop (incl. EMR), even if the
+# mesos slaves on which execution happens do not have
+# Hadoop installed. Included wrapper scripts allow
+# transfering files and executing them on a remote machine
+# in the background and using asynchronous callbacks to
+# notify Chronos of job completion or failures.
+# See https://github.com/airbnb/chronos for more info.
+### END INIT INFO
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+DESC="chronos daemon"
+NAME=chronos
+DAEMON=/usr/bin/java
+PIDFILE=/var/run/${NAME}.pid
+SCRIPTNAME=$0
+
+# set these to match your environment
+CHRONOS_HOME=/home/asemenov/chronos
+MESOS_HOME=/opt/mesos
+
+if [ "$(id -u)" -ne "0" ]; then
+ echo "you must be root to start ${DESC}"
+ exit 1
+fi
+
+. /lib/lsb/init-functions
+
+[ -r /etc/default/chronos ] && . /etc/default/chronos
+
+# Read the system's locale and set cron's locale. This is only used for
+# setting the charset of mails generated by cron. To provide locale
+# information to tasks running under cron, see /etc/pam.d/cron.
+#
+# We read /etc/environment, but warn about locale information in
+# there because it should be in /etc/default/locale.
+set_environment () {
+ libmesos_file=$(find ${MESOS_HOME} -name "libmesos.dylib" -or -name "libmesos.so" | head -n1)
+ build_env=$(find ${MESOS_HOME} -name "mesos-build-env.sh" | head -n1)
+ chronos_jar_file=$(find ${CHRONOS_HOME} -name "chronos-*.jar" | grep -v sources | head -n1)
+ export MESOS_NATIVE_LIBRARY="${libmesos_file}"
+ . $build_env
+ EXTRA_OPTS="-cp $chronos_jar_file com.airbnb.scheduler.Main server "$CHRONOS_HOME"/config/local_scheduler_nozk.yml"
+}
+
+case "$1" in
+ start)
+ set_environment
+ log_daemon_msg "Starting periodic command scheduler" "cron"
+ ### example starting chronos from command line
+ ### java -cp $chronos_jar_file com.airbnb.scheduler.Main server "$CHRONOS_HOME"/config/local_scheduler_nozk.yml
+ ### example startin chronos with start_daemon
+ ### start_daemon -p $PIDFILE $DAEMON $EXTRA_OPTS
+
+ # best way to daemonize, imho
+ start-stop-daemon --start --quiet --background \
+ --pidfile $PIDFILE --make-pidfile \
+ --exec $DAEMON -- $EXTRA_OPTS
+ log_end_msg $?
+ ;;
+ stop)
+ log_daemon_msg "Stopping periodic command scheduler" "${NAME}"
+ killproc -p $PIDFILE $DAEMON
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE
+ log_end_msg $RETVAL
+ ;;
+ restart)
+ log_daemon_msg "Restarting periodic command scheduler" "${NAME}"
+ $0 stop
+ sleep 5
+ $0 start
+ ;;
+ reload|force-reload)
+ log_daemon_msg "Reloading configuration files for periodic command scheduler" "${NAME}"
+ # cron reloads automatically
+ log_end_msg 0
+ ;;
+ status)
+ status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
+ ;;
+ *)
+ log_action_msg "Usage: ${SCRIPTNAME} {start|stop|status|restart|reload|force-reload}"
+ exit 2
+ ;;
+esac
+exit 0
View
@@ -9,7 +9,7 @@ declare -r DEFAULT_MESOS_JAR_STRING="0.12.0-SNAPSHOT_JDK1.7"
detected_os="$(uname)"
case $detected_os in
Linux)
- sed_in_place() {
+ sed_in_place() {
sed -i $@
}
;;

0 comments on commit 4705f50

Please sign in to comment.