start-port.sh 661 B

123456789101112131415161718192021222324
  1. #!/usr/bin/sh
  2. if [ $# -ne 2 ] && [ $# -ne 3 ]
  3. then
  4. echo "Usage: start-port.sh app port [profile]"
  5. echo Example: ./start-port.sh demo-1.0.0.jar 8081 prod
  6. exit
  7. fi
  8. app=$1
  9. port=$2
  10. profile=$3
  11. if test $# -ne 3
  12. then
  13. profile=prod
  14. fi
  15. pid=`netstat -npa|grep LISTEN|grep $port|awk '{print $7}'|awk -F '/' '{print $1}'`
  16. if [ -z $pid ]
  17. then
  18. #nohup java -jar $app --server.port=$port --spring.profiles.active=$profile &
  19. nohup java -cp $app -Dloader.path=lib -Djava.libraray.path=lib -Dserver.port=$port -Dspring.profiles.active=$profile org.springframework.boot.loader.PropertiesLauncher &
  20. echo 'Start service ok!'
  21. else
  22. echo 'Error: service is started!'
  23. fi