Skip to content

Commit

Permalink
new:usr:Improve RPM package with configuration and scripts (qubole#52)
Browse files Browse the repository at this point in the history
This commit adds 
* configuration files for bookkeeper and lds.
* Start/Stop scripts
* Sets up run, log and conf directories.
Tested using rubix-admin on Qubole clusters.
  • Loading branch information
vrajat authored Aug 4, 2017
1 parent 3d8f841 commit 875fde2
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 6 deletions.
37 changes: 31 additions & 6 deletions rubix-rpm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<configuration>
<name>qubole-rubix</name>
<copyright>2015, Qubole</copyright>
<architecture>x86_64</architecture>
<group>Applications/Databases</group>
<description>RPM Package for Rubix (https://github.com/qubole/rubix</description>
<mappings>
Expand All @@ -90,19 +91,43 @@
<artifact/>
</mapping>
<mapping>
<directory>${app.home}/conf</directory>
<!-- <configuration>true</configuration>
<directory>${app.home}/bin</directory>
<filemode>755</filemode>
<sources>
<source>
<location>${project.build.outputDirectory}/app.properties</location>
<destination>app.sample.properties</destination>
<location>src/main/resources/rpm/init.d/rubix.service</location>
</source>
</sources>-->
</sources>
</mapping>
<mapping>
<directory>${app.home}/logs</directory>
<directory>/etc/rubix/</directory>
<configuration>true</configuration>
<sources>
<source>
<location>src/main/resources/rpm/config/log4j.properties</location>
</source>
<source>
<location>src/main/resources/rpm/config/log4j_lds.properties</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/var/log/rubix/</directory>
<filemode>755</filemode>
<username>ec2-user</username>
<groupname>ec2-user</groupname>
</mapping>
<mapping>
<directory>/var/run/rubix/</directory>
<filemode>755</filemode>
<username>ec2-user</username>
<groupname>ec2-user</groupname>
</mapping>
</mappings>
<postinstallScriptlet>
<scriptFile>src/main/resources/rpm/scripts/postinst</scriptFile>
<fileEncoding>utf-8</fileEncoding>
</postinstallScriptlet>
</configuration>
</plugin>
</plugins>
Expand Down
8 changes: 8 additions & 0 deletions rubix-rpm/src/main/resources/rpm/config/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
log4j.rootLogger=WARN, R

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/var/log/rubix/bks.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=2
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss,SSS} %p %t %c{2}: %m%n
8 changes: 8 additions & 0 deletions rubix-rpm/src/main/resources/rpm/config/log4j_lds.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
log4j.rootLogger=WARN, R

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/var/log/rubix/lds.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=2
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss,SSS} %p %t %c{2}: %m%n
67 changes: 67 additions & 0 deletions rubix-rpm/src/main/resources/rpm/init.d/rubix.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash -e

d=`dirname $0`
d=`cd "$d"; pwd`

RUN_DIR=/var/run/rubix
PID_FILE=${RUN_DIR}/bks.pid
PID_FILE_2=${RUN_DIR}/lts.pid
MONITRC_FILE=/etc/monit.d/bks.cfg
LOG4J_FILE=/etc/rubix/log4j.properties
LOG4J_FILE_LDS=/etc/rubix/log4j_lds.properties

LOG_DIR=/var/logs/rubix
LOG_FILE=${LOG_DIR}/bks.log
LOG_FILE_LDS=${LOG_DIR}/lds.log

# increase mmap system limit
sudo sysctl -w vm.max_map_count=200000

usage() {
echo "Usage: $0"
echo "$1"
echo "start and stop the Cache BookKeeper Server."
echo "$0 [start|stop]"
exit $2
}

start() {
export HADOOP_OPTS="-Dlog4j.configuration=file://${LOG4J_FILE}"
# Set the fs impls as CachingNativeS3FileSystem for book-keeper.
ulimit -n 100000
nohup /usr/lib/hadoop2/bin/hadoop jar /usr/lib/rubix/lib/rubix-bookkeeper-*.jar com.qubole.rubix.bookkeeper.BookKeeperServer &

PID=$!
echo $PID > ${PID_FILE}

echo "Starting Cache BookKeeper server with pid `cat ${PID_FILE}`"
export HADOOP_OPTS="-Dlog4j.configuration=file://${LOG4J_FILE_LDS}"
nohup /usr/lib/hadoop2/bin/hadoop jar /usr/lib/rubix/lib/rubix-bookkeeper-*.jar com.qubole.rubix.bookkeeper.LocalDataTransferServer &
PIDL=$!
echo $PIDL > ${PID_FILE_2}
echo "Starting Local Transfer server with pid $PIDL"
sleep 1
}

stop() {
kill -9 `cat ${PID_FILE}`
kill -9 `cat ${PID_FILE_2}`
rm -f ${PID_FILE}
rm -f ${PID_FILE_2}
}

restart() {
stop
start
}
cmd=$1

case "$cmd" in
start) start;;
stop) stop;;
restart) restart;;
help) usage "" 0;;
*) usage "ERROR: Incorrect arguments" 1;;
esac

exit 0;
1 change: 1 addition & 0 deletions rubix-rpm/src/main/resources/rpm/scripts/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cp /usr/lib/rubix/bin/rubix.service /etc/init.d

0 comments on commit 875fde2

Please sign in to comment.