修改
This commit is contained in:
parent
177e1c16e5
commit
7d2fac006c
35
index.py
35
index.py
@ -109,6 +109,33 @@ def startw():
|
|||||||
# 开启cmd来执行bat文件,以便查看执行情况
|
# 开启cmd来执行bat文件,以便查看执行情况
|
||||||
os.system("start temp.bat")
|
os.system("start temp.bat")
|
||||||
|
|
||||||
|
# 服务中心启动
|
||||||
|
def startCenter():
|
||||||
|
server = getServer()
|
||||||
|
|
||||||
|
# 构建执行bat
|
||||||
|
bat = f'''@echo off
|
||||||
|
cd {server["dir"]}
|
||||||
|
SET port={server["port"]}
|
||||||
|
for /f "usebackq tokens=1-5" %%a in (`netstat -ano ^| findstr %port%`) do (
|
||||||
|
if [%%d] EQU [LISTENING] (
|
||||||
|
set pid=%%e
|
||||||
|
)
|
||||||
|
)
|
||||||
|
echo close : %port% %pid%
|
||||||
|
if not "%pid%" == "" taskkill /f /pid %pid%
|
||||||
|
|
||||||
|
sc start {server["name"]}
|
||||||
|
echo start {server["name"]}
|
||||||
|
|
||||||
|
pause
|
||||||
|
exit'''
|
||||||
|
file = open("temp.bat", 'w', encoding='utf-8')
|
||||||
|
file.write(bat)
|
||||||
|
file.close()
|
||||||
|
# 开启cmd来执行bat文件,以便查看执行情况
|
||||||
|
os.system("start temp.bat")
|
||||||
|
|
||||||
# 停止服务
|
# 停止服务
|
||||||
def stop():
|
def stop():
|
||||||
server = getServer()
|
server = getServer()
|
||||||
@ -153,7 +180,7 @@ def install():
|
|||||||
<log mode="none"/>
|
<log mode="none"/>
|
||||||
</service>
|
</service>
|
||||||
'''
|
'''
|
||||||
file = open(f'{server["dir"]}/server.xml', 'w', encoding='utf-8')
|
file = open(f'{server["dir"]}/{server["name"]}.xml', 'w', encoding='utf-8')
|
||||||
file.write(xml)
|
file.write(xml)
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
@ -165,7 +192,7 @@ def install():
|
|||||||
sc delete {server["name"]}
|
sc delete {server["name"]}
|
||||||
echo uninstall {server["name"]}
|
echo uninstall {server["name"]}
|
||||||
|
|
||||||
WinSW-x64.exe install {server["dir"]}\server.xml
|
WinSW-x64.exe install {server["dir"]}\{server["name"]}.xml
|
||||||
echo install {server["name"]}
|
echo install {server["name"]}
|
||||||
|
|
||||||
sc start {server["name"]}
|
sc start {server["name"]}
|
||||||
@ -206,7 +233,7 @@ window = Tk()
|
|||||||
# 第2步,给窗口的可视化起名字
|
# 第2步,给窗口的可视化起名字
|
||||||
window.title('window下SpringBoot部署程序')
|
window.title('window下SpringBoot部署程序')
|
||||||
# 第3步,设定窗口的大小(长 * 宽)
|
# 第3步,设定窗口的大小(长 * 宽)
|
||||||
window.geometry('850x250') # 这里的乘是小x
|
window.geometry('900x250') # 这里的乘是小x
|
||||||
window.configure(bg='#FFFFFF') # 这里的乘是小x
|
window.configure(bg='#FFFFFF') # 这里的乘是小x
|
||||||
|
|
||||||
## 渲染各个服务 - 设置单选
|
## 渲染各个服务 - 设置单选
|
||||||
@ -222,6 +249,7 @@ buttonFrame.pack(pady=20)
|
|||||||
|
|
||||||
stratButton = Button(buttonFrame, text='启动(控制台)', command=start)
|
stratButton = Button(buttonFrame, text='启动(控制台)', command=start)
|
||||||
stratwButton = Button(buttonFrame, text='启动(后台)', command=startw)
|
stratwButton = Button(buttonFrame, text='启动(后台)', command=startw)
|
||||||
|
stratCenterButton = Button(buttonFrame, text='启动(服务中心)', command=startCenter)
|
||||||
stopButton = Button(buttonFrame, text='停止服务', command=stop)
|
stopButton = Button(buttonFrame, text='停止服务', command=stop)
|
||||||
installButton = Button(buttonFrame, text='安装服务(使用winsw安装到系统服务上)', command=install)
|
installButton = Button(buttonFrame, text='安装服务(使用winsw安装到系统服务上)', command=install)
|
||||||
unInstallButton = Button(buttonFrame, text='卸载服务(从系统服务上卸载)', command=unInstall)
|
unInstallButton = Button(buttonFrame, text='卸载服务(从系统服务上卸载)', command=unInstall)
|
||||||
@ -229,6 +257,7 @@ updateStateButton = Button(buttonFrame, text='刷新服务状态', command=lambd
|
|||||||
|
|
||||||
stratButton.pack(side=LEFT, padx=10)
|
stratButton.pack(side=LEFT, padx=10)
|
||||||
stratwButton.pack(side=LEFT, padx=10)
|
stratwButton.pack(side=LEFT, padx=10)
|
||||||
|
stratCenterButton.pack(side=LEFT, padx=10)
|
||||||
stopButton.pack(side=LEFT, padx=10)
|
stopButton.pack(side=LEFT, padx=10)
|
||||||
installButton.pack(side=LEFT, padx=10)
|
installButton.pack(side=LEFT, padx=10)
|
||||||
unInstallButton.pack(side=LEFT, padx=10)
|
unInstallButton.pack(side=LEFT, padx=10)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user