tomas
tomas

Reputation: 840

Installing Spring Boot Application on Linux System

Enviroment:

I have used the Spring Docu:

https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html

And so i created a symbolic link (etc/init.d/myService). And everythink works fine. I can controll my service via: sudo service myService start|stop|staus

But unfortunately i am not allowed to put a symbolic link within /etc/init.d

I have tried to put a script myService within /etc/init.d and this script contains only one row:

/work/springBoot/myService.jar

But now when i enter

sudo service myService status

The spring boot application starts. And not the status is displayed. So what can i do?

Upvotes: 0

Views: 1221

Answers (1)

tomas
tomas

Reputation: 840

This works for me:

#!/bin/bash
# chkconfig: 345 20 80
SPRING_BOOT_JAR=myService-0.1.1.jar
SPRING_BOOT_DIR=/work/springboot/myService
EXECUTABLE=$SPRING_BOOT_DIR/$SPRING_BOOT_JAR

export OUT_LOG="$SPRING_BOOT_DIR/out.log"
export MODE="service"

start() {

echo "Start was called for " + $EXECUTABLE
nohup $SPRING_BOOT_DIR/$SPRING_BOOT_JAR start > $OUT_LOG 2>&1 &

}

stop() {

echo "Stop was called for " + $EXECUTABLE
$SPRING_BOOT_DIR/$SPRING_BOOT_JAR stop

}

status() {

echo "Status was called for " + $EXECUTABLE
$SPRING_BOOT_DIR/$SPRING_BOOT_JAR "status"

}

case "$1" in

start)
    start
    ;;
stop)
    stop
    ;;
status)
    status
    ;;
*)
    echo "Please use start|stop|status"
    exit 1
    ;;
esac

exit

The trick was

export MODE="service"

Upvotes: 0

Related Questions