Windows和Linux服务启动脚本

Windows和Linux服务启动脚本

一后端 Windows启动脚本

方式一

//startUser.bat
TITLE user
java -jar -Xms128m -Xmx128m  honlitech-cloud-acl-application-0.0.1-SNAPSHOT.jar

方式二:可在idea上进行启动

TITLE chery-tms
set name=honlitech-cloud-tms-application-1.0.0-SNAPSHOT
set active=local
set port=1155
mode con cols=100 lines=30
chcp 65001
for %%a in (%port%) do (
    set pid=0
    for /f "tokens=2,5" %%b in ('netstat -ano ^| findstr ":%%a"') do (
        set temp=%%b
        for /f "usebackq delims=: tokens=1,2" %%i in (`set temp`) do (
            if %%j==%%a (
                taskkill /f /pid %%c
                set pid=%%c
                echo success kill port:%prot%%%a】
            ) else (
                echo port:%prot% not use【%%a】
            )
        )
    )
    if !pid!==0 (
        echo port:%prot% not use【%%a】
    )
)
echo close java project --------------------------------------------
ping 127.0.0.1 -n 3
echo start java project name=%name%,active=%active%,port:%port%
java -Xms128m -Xmx256m -Xss256k -jar -Dspring.profiles.active=%active%  -DHONLITECH-EUREAK-HOSTS=http://192.168.1.227:1105/eureka/ -DHONLITECH-CONFIG-URI=http://192.168.1.227:1115 %name%.jar --server.port=%port%
exit

二 后端 Linux启动脚本

#!/bin/bash
java -Xms128m -Xmx128m -jar -DHONLITECH-EUREAK-HOSTS=http://192.168.1.247:1100/eureka/ -Dspring.profiles.active=test -DHONLITECH-CONFIG-URI=http://192.168.1.247:1110 /home/dsp_test_jars/jars/honlitech-cloud-acl-application-0.0.1-SNAPSHOT.jar &

三 前端Linux启动脚本

docker run -p 8110:80 -d --restart=always --name dspnginxtest -v /app/dspnginxtest/www:/usr/share/nginx/html:ro -v /app/dspnginxtest/conf/nginx.conf:/etc/nginx/nginx.conf:ro -v /home/dspnginxtest/logs:/var/log/nginx nginx:1.21

三 启动consul脚本

(1)Windows版

TITLE chery-consul
set port=8500

mode con cols=100 lines=30
chcp 65001
@echo off&color 0
if exist "%SystemRoot%\SysWOW64" path %path%;%windir%\SysNative;%SystemRoot%\SysWOW64;%~dp0
bcdedit >nul
if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin)
:UACPrompt
%1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit
exit /B
:UACAdmin
cd /d "%~dp0"
echo path:%CD%

//关闭java进程
for %%a in (%port%) do (
    set pid=0
    for /f "tokens=2,5" %%b in ('netstat -ano ^| findstr ":%%a"') do (
        set temp=%%b
        for /f "usebackq delims=: tokens=1,2" %%i in (`set temp`) do (
            if %%j==%%a (
                taskkill /f /pid %%c
                set pid=%%c
                echo success kill port:%prot%【%%a】
            ) else (
                echo port:%prot% not use【%%a】
            )
        )
    )
    if !pid!==0 (
        echo port:%prot% not use【%%a】
    )
)
echo close java project --------------------------------------------
//为了保险起见等待进程3s关闭结束
ping 127.0.0.1 -n 3
echo  project port:%port%


consul agent -server -bootstrap-expect 1 -data-dir F:\chery_local_mysql\chery\consul_1.13.1\data -node=consulServer1 -bind=192.168.1.227 -ui -config-dir=F:\chery_local_mysql\chery\consul_1.13.1\config -client 0.0.0.0

(2)Linux版

docker run -d --name=consul --net=host -v $PWD/data:/consul/data \
-p8500:8500 -p 8300:8300 -p 8301:8301 -p 8302:8302 -p 8600:8600 \
consul:1.13.1 agent -server -bind=192.168.1.250 -bootstrap-expect=1 -ui -client=0.0.0.0

你可能感兴趣的:(Linux学习笔记,启动脚本)