Skip to content

Commit

Permalink
Add daemon script and configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
Leemoonsoo committed Sep 8, 2013
1 parent d0845d8 commit a7a6397
Show file tree
Hide file tree
Showing 6 changed files with 317 additions and 0 deletions.
91 changes: 91 additions & 0 deletions bin/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash
#
#/**
# * Copyright 2007 The Apache Software Foundation
# *
# * Licensed to the Apache Software Foundation (ASF) under one
# * or more contributor license agreements. See the NOTICE file
# * distributed with this work for additional information
# * regarding copyright ownership. The ASF licenses this file
# * to you under the Apache License, Version 2.0 (the
# * "License"); you may not use this file except in compliance
# * with the License. You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */

FWDIR="$(cd `dirname $0`; pwd)"
ZEPPELIN_HOME=$FWDIR/..

if [ "x$ZEPPELIN_CONF_DIR" == "x" ] ; then
export ZEPPELIN_CONF_DIR="$ZEPPELIN_HOME/conf"
fi

if [ "x$ZEPPELIN_LOG_DIR" == "x" ]; then
export ZEPPELIN_LOG_DIR="$ZEPPELIN_HOME/logs"
fi

if [ "x$ZEPPELIN_DATA_DIR" == "x" ]; then
export ZEPPELIN_DATA_DIR="$ZEPPELIN_HOME/data"
fi

if [ "x$ZEPPELIN_PID_DIR" == "x" ]; then
export ZEPPELIN_PID_DIR="$ZEPPELIN_HOME/run"
fi


if [ -f "${ZEPPELIN_CONF_DIR}/zeppelin-env.sh" ]; then
. "${ZEPPELIN_CONF_DIR}/zeppelin-env.sh"
fi

ZEPPELIN_CLASSPATH+=:${ZEPPELIN_CONF_DIR}


function addJarInDir(){
if [ -d "${1}" ]; then
for jar in `find ${1} -name '*jar'`; do
ZEPPELIN_CLASSPATH+=:$jar
done
fi
}

addJarInDir ${ZEPPELIN_HOME}
addJarInDir ${ZEPPELIN_HOME}/lib
addJarInDir ${ZEPPELIN_HOME}/zeppelin-core/target/lib
addJarInDir ${ZEPPELIN_HOME}/zeppelin-server/target/lib
addJarInDir ${ZEPPELIN_HOME}/zeppelin-web/target/lib
addJarInDir ${ZEPPELIN_HOME}/zeppelin-cli/target/lib


if [ -d "${ZEPPELIN_HOME}/zeppelin-core/target/classes" ]; then
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/zeppelin-core/target/classes"
fi

if [ -d "${ZEPPELIN_HOME}/zeppelin-server/target/classes" ]; then
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/zeppelin-server/target/classes"
fi


export ZEPPELIN_CLASSPATH
export CLASSPATH+=${ZEPPELIN_CLASSPATH}

JAVA_OPTS+="$ZEPPELIN_JAVA_OPTS"

if [ -n "$JAVA_HOME" ]; then
ZEPPELIN_RUNNER="${JAVA_HOME}/bin/java"
else
ZEPPELIN_RUNNER=java
fi

export RUNNER


if [ "x$ZEPPELIN_IDENT_STRING" == "x" ]; then
export ZEPPELIN_IDENT_STRING="$USER"
fi
35 changes: 35 additions & 0 deletions bin/zeppelin
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

#
#/**
# * Copyright 2007 The Apache Software Foundation
# *
# * Licensed to the Apache Software Foundation (ASF) under one
# * or more contributor license agreements. See the NOTICE file
# * distributed with this work for additional information
# * regarding copyright ownership. The ASF licenses this file
# * to you under the Apache License, Version 2.0 (the
# * "License"); you may not use this file except in compliance
# * with the License. You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */

usage="Usage: zeppelin [-h <host addr>] [-p <Port>]\
<command...>"

# if no args specified, show usage
if [ $# -le 1 ]; then
echo $usage
exit 1
fi

bin=`dirname "${BASH_SOURCE-$0}"`
bin=`cd "$bin">/dev/null; pwd`

110 changes: 110 additions & 0 deletions bin/zeppelin-daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash
#
#/**
# * Copyright 2007 The Apache Software Foundation
# *
# * Licensed to the Apache Software Foundation (ASF) under one
# * or more contributor license agreements. See the NOTICE file
# * distributed with this work for additional information
# * regarding copyright ownership. The ASF licenses this file
# * to you under the Apache License, Version 2.0 (the
# * "License"); you may not use this file except in compliance
# * with the License. You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */
#
# Runs Zeppelin daemon
#
#

usage="Usage: zeppelin-daemon.sh [--config <conf-dir>]\
(start|stop|restart) \
<args...>"

# if no args specified, show usage
if [ $# -le 0 ]; then
echo $usage
exit 1
fi

bin=`dirname "${BASH_SOURCE-$0}"`
bin=`cd "$bin">/dev/null; pwd`

. $bin/common.sh


# get arguments
startStop=$1
shift
args=$1
shift



HOSTNAME=`hostname`
ZEPPELIN_LOGFILE=ZEPPELIN_LOG_DIR/zeppelin-$ZEPPELIN_IDENT_STRING-$HOSTNAME.log
log=$ZEPPELIN_LOG_DIR/zeppelin-$ZEPPELIN_IDENT_STRING-$HOSTNAME.out
pid=$ZEPPELIN_PID_DIR/zeppelin-$ZEPPELIN_IDENT_STRING-$HOSTNAME.pid


if [ "${ZEPPELIN_NICENESS}" = "" ]; then
export ZEPPELIN_NICENESS=0
fi

ZEPPELIN_MAIN=org.apache.zeppelin.server.ZeppelinServer

case $startStop in
(start)
if [ -f "$pid" ]; then
if kill -0 `cat $pid` > /dev/null 2>&1; then
echo zeppelin running as process `cat $pid`. Stop it first.
exit 1
fi
fi

if [ ! -d "$ZEPPELIN_LOG_DIR" ]; then
echo "Log dir doesn't exist, create $ZEPPELIN_LOG_DIR"
mkdir -p "$ZEPPELIN_LOG_DIR"
fi

if [ ! -d "$ZEPPELIN_PID_DIR" ]; then
echo "Pid dir doesn't exist, create $ZEPPELIN_PID_DIR"
mkdir -p "$ZEPPELIN_PID_DIR"
fi


nohup nice -n $ZEPPELIN_NICENESS $ZEPPELIN_RUNNER $ZEPPELIN_MAIN -cp $CLASSPATH $JAVA_OPTS "$@" >> "$log" 2>&1 < /dev/null &
newpid=$!
echo $newpid > $pid
sleep 2
# Check if the process has died; in that case we'll tail the log so the user can see
if ! kill -0 $newpid >/dev/null 2>&1; then
echo "failed to launch Zeppelin:"
tail -2 "$log" | sed 's/^/ /'
echo "full log in $log"
fi
;;
(stop)
if [ -f $pid ]; then
if kill -0 `cat $pid` > /dev/null 2>&1; then
echo stopping Zeppelin
kill `cat $pid`
else
echo no Zeppelin to stop
fi
else
echo no Zeppelin to stop
fi
;;
(*)
echo $usage
exit 1
;;
esac
41 changes: 41 additions & 0 deletions conf/configuration.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="configuration">
<html>
<body>
<table border="1">
<tr>
<td>name</td>
<td>value</td>
<td>description</td>
</tr>
<xsl:for-each select="property">
<tr>
<td><a name="{name}"><xsl:value-of select="name"/></a></td>
<td><xsl:value-of select="value"/></td>
<td><xsl:value-of select="description"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
12 changes: 12 additions & 0 deletions conf/zeppelin-env.sh.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash



# ZEPPELIN_PORT Zeppelin port number
# ZEPPELIN_CONF_DIR Alternate zeppelin conf dir. Default is ${HBASE_HOME}/conf.
# ZEPPELIN_LOG_DIR Where log files are stored. PWD by default.
# ZEPPELIN_PID_DIR The pid files are stored. /tmp by default.
# ZEPPELIN_DATA_DIR The pid files are stored. /tmp by default.
# ZEPPELIN_IDENT_STRING A string representing this instance of zeppelin. $USER by default
# ZEPPELIN_NICENESS The scheduling priority for daemons. Defaults to 0.
# ZEPPELIN_JAVA_OPTS
28 changes: 28 additions & 0 deletions conf/zeppelin-site.xml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->


<configuration>
<property>
<name>zeppelin.driver.class</name>
<value>org.apache.driver.Driver</value>
<description>Zeppelin driver name</description>
</property>
</configuration>

0 comments on commit a7a6397

Please sign in to comment.