Making shell scripts for spring boot executables

Source: Internet
Author: User

After the Spring boot project is packaged into an executable jar, for ease of management, we can make a script that manages the steps of starting, stopping, and so on. Instructions for use

Assuming that the script is eventually named App.sh, you can do the following:

# Show Application Status
app status

# foreground start app
run

# background start app start

# Close app
stop app

Background to start the application, you should enter a carriage return, back to the terminal and then exit the terminal, if the application may exit the background run full script

#!/bin/bash
If ["$" = "Run"] then
    java-jar application-name.jar
else if ["$" = "start"]; then
    no Hup Java-jar Application-name.jar &
    echo "Application is starting."
else if ["$" = "Stop"];  Then
    pid=$ (ps-ef | grep application-name.jar | grep-v grep | awk ' {print $} ')
    if [-Z "$PID"]; then
        Echo Application is already stopped
    else
        echo kill $PID
        kill $PID
    fi
else if ["$" = "status"];  N
    pid=$ (ps-ef | grep application-name.jar | grep-v grep | awk ' {print $} ')
    if [-Z "$PID"]; then
        Echo Application is stopped
    else
        Echo application is running
        echo $PID
    fi
fi fi
fi

Application-name for Application name Other instructions app.sh should configure executable permissions script to use Nohup guarantee application to run continuously in the background

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.