Skip to content

宝塔运维

通用项目

某些场景下,需要自定义项目启动脚本

通用项目启动脚本

原理:启动成功后,将项目的进程ID写入指定文件即可/var/tmp/other_project/项目名称.pid

bash
#! /bin/bash

echo 
echo 
echo ----------------------------
echo --- start ....
date

cd /opt/docker/fastposter-pro-java/
docker-compose up -d
sleep 1

ps aux |grep fastposter-pro.jar
echo -------------------------------

pid=$(ps aux |grep fastposter-pro.jar | grep -v grep | awk '{print $2}')
echo $pid
echo "$pid" > /var/tmp/other_project/fastposter.pid

echo --- done

image-20230530181142175

人生感悟