Commit 64421604 authored by Georgios Ouzounis's avatar Georgios Ouzounis

LAM-49 Apache Zookeeper and Kafka init scripts are run by kafka user.

parent 32fa0262
#!/bin/bash
# Define the user that should run the service.
SERVICE_USER=kafka
# Define the group in which SERVICE_USER belongs.
SERVICE_GROUP=lambda
# The path where Apache Kafka is installed.
INSTALLATION_PATH="{{ installation_path }}"
......@@ -13,15 +19,22 @@ LOCKFILE="$INSTALLATION_PATH/kafka/kafka-lock"
START_COMMAND="$INSTALLATION_PATH/kafka/bin/kafka-server-start.sh $INSTALLATION_PATH/kafka/config/server.properties"
start(){
touch $PIDFILE
nohup $START_COMMAND > /dev/null & echo $! > $PIDFILE
/sbin/start-stop-daemon --start --background --chuid $SERVICE_USER:$SERVICE_GROUP --make-pidfile --pidfile $PIDFILE --exec $START_COMMAND
chown $SERVICE_USER $PIDFILE
chgrp $SERVICE_GROUP $PIDFILE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
chown $SERVICE_USER $LOCKFILE
chgrp $SERVICE_GROUP $LOCKFILE
return $RETVAL
}
stop(){
kill -s 9 $(cat $PIDFILE)
/sbin/start-stop-daemon --stop --remove-pidfile --pidfile $PIDFILE
RETVAL=$?
[ $RETVAL -eq 0 ] && $(rm -f $LOCKFILE)
return $RETVAL
......
#!/bin/bash
# Define the user that should run the service.
SERVICE_USER=kafka
# Define the group in which SERVICE_USER belongs.
SERVICE_GROUP=lambda
# The path where Apache Zookeeper is installed.
INSTALLATION_PATH="{{ installation_path }}"
......@@ -13,10 +19,17 @@ LOCKFILE="$INSTALLATION_PATH/kafka/zookeeper-lock"
START_COMMAND="$INSTALLATION_PATH/kafka/bin/zookeeper-server-start.sh $INSTALLATION_PATH/kafka/config/zookeeper.properties"
start(){
touch $PIDFILE
nohup $START_COMMAND > /dev/null & echo $! > $PIDFILE
/sbin/start-stop-daemon --start --background --chuid $SERVICE_USER:$SERVICE_GROUP --make-pidfile --pidfile $PIDFILE --exec $START_COMMAND
chown $SERVICE_USER $PIDFILE
chgrp $SERVICE_GROUP $PIDFILE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
chown $SERVICE_USER $LOCKFILE
chgrp $SERVICE_GROUP $LOCKFILE
return $RETVAL
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment