Commit 64421604 authored by Georgios Ouzounis's avatar Georgios Ouzounis
Browse files

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

parent 32fa0262
#!/bin/bash #!/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. # The path where Apache Kafka is installed.
INSTALLATION_PATH="{{ installation_path }}" INSTALLATION_PATH="{{ installation_path }}"
...@@ -13,15 +19,22 @@ LOCKFILE="$INSTALLATION_PATH/kafka/kafka-lock" ...@@ -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_COMMAND="$INSTALLATION_PATH/kafka/bin/kafka-server-start.sh $INSTALLATION_PATH/kafka/config/server.properties"
start(){ start(){
touch $PIDFILE /sbin/start-stop-daemon --start --background --chuid $SERVICE_USER:$SERVICE_GROUP --make-pidfile --pidfile $PIDFILE --exec $START_COMMAND
nohup $START_COMMAND > /dev/null & echo $! > $PIDFILE
chown $SERVICE_USER $PIDFILE
chgrp $SERVICE_GROUP $PIDFILE
RETVAL=$? RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE [ $RETVAL -eq 0 ] && touch $LOCKFILE
chown $SERVICE_USER $LOCKFILE
chgrp $SERVICE_GROUP $LOCKFILE
return $RETVAL return $RETVAL
} }
stop(){ stop(){
kill -s 9 $(cat $PIDFILE) /sbin/start-stop-daemon --stop --remove-pidfile --pidfile $PIDFILE
RETVAL=$? RETVAL=$?
[ $RETVAL -eq 0 ] && $(rm -f $LOCKFILE) [ $RETVAL -eq 0 ] && $(rm -f $LOCKFILE)
return $RETVAL return $RETVAL
......
#!/bin/bash #!/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. # The path where Apache Zookeeper is installed.
INSTALLATION_PATH="{{ installation_path }}" INSTALLATION_PATH="{{ installation_path }}"
...@@ -13,10 +19,17 @@ LOCKFILE="$INSTALLATION_PATH/kafka/zookeeper-lock" ...@@ -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_COMMAND="$INSTALLATION_PATH/kafka/bin/zookeeper-server-start.sh $INSTALLATION_PATH/kafka/config/zookeeper.properties"
start(){ start(){
touch $PIDFILE /sbin/start-stop-daemon --start --background --chuid $SERVICE_USER:$SERVICE_GROUP --make-pidfile --pidfile $PIDFILE --exec $START_COMMAND
nohup $START_COMMAND > /dev/null & echo $! > $PIDFILE
chown $SERVICE_USER $PIDFILE
chgrp $SERVICE_GROUP $PIDFILE
RETVAL=$? RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE [ $RETVAL -eq 0 ] && touch $LOCKFILE
chown $SERVICE_USER $LOCKFILE
chgrp $SERVICE_GROUP $LOCKFILE
return $RETVAL 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