feifan-app-server.sh 877 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. app_name='feifan-server'
  3. module_name='app'
  4. current_time=$(date +"%Y-%m-%d %H:%M:%S")
  5. port=48080
  6. pid=$(lsof -ti :$port)
  7. # 备份原来的jar包
  8. cd /data/projects/backend/${module_name}
  9. mv ${app_name}.jar ${app_name}-${current_time}.jar
  10. pwd
  11. ls
  12. cd /data/jenkins_home/workspace/feifan-backend-zx-${module_name}/${app_name}/target
  13. pwd
  14. ls
  15. # 获取jar包, 直接运行
  16. echo "--- 开始执行 ${app_name} 项目 ---"
  17. if [ -z "${pid}" ]; then
  18. echo "端口 ${port} 未被占用。"
  19. else
  20. kill -9 ${pid}
  21. echo "进程 ${pid} 已被终止。"
  22. fi
  23. echo '----启动项目 60s后结束控制台信息----'
  24. mv ./${app_name}.jar /data/projects/backend/${module_name}
  25. cd /data/projects/backend/${module_name}
  26. nohup /usr/local/jar/jdk1.8.0_371/bin/java -jar ${app_name}.jar > nohup.log 2>&1 &
  27. timeout 60s tail -f -n 1000 nohup.log
  28. echo '----项目启动成功----'