更新服务

This commit is contained in:
24kycj
2024-12-06 20:28:24 +08:00
parent ef7eab3cf9
commit dddb5dd918
52 changed files with 172 additions and 14 deletions
Binary file not shown.
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
[system_setting]
downDevicePath=/dev/sr1
downDeviceType=0
end_time=cWL0ocEfX1NTQW0+hs3SGnKIgYkMeNru
logLevel=1
retryFreq=2
serverPath=/home/test/CDCache
server_name=127.0.0.1
server_port=10010
topDevicePath=/dev/sr0
topDeviceType=0
update_time=iWfJMJHeTnMCacgifeF9oACX0fK8UsnmNBUJgTgF2cs=
+80
View File
@@ -0,0 +1,80 @@
#!/bin/bash
# 路径
HOME=$(cd $(dirname $0);pwd)
# 启动
start(){
cd $HOME
# 将C++程序后台启动,并将启动日志指向springBootThree-1.0.log中
spid=$(pgrep -f "controlServer") #$(ps -ef | grep "[m]controlServer" | grep -v grep | awk '{print $2}')
if [ -z "$spid" ]
then
./controlServer > /dev/null 2>&1 &
# 打印字符串
echo "启动成功"
else
echo Application is already started
fi
}
# 停止
stop(){
# 查询到项目的pid
tpid=$(pgrep -f "controlServer") #$(ps -ef | grep "[m]controlServer" | grep -v grep | awk '{print $2}')
# 判断是否为空
if [ -z "$tpid" ]
then
# 如果为空 则打印这句话
echo Application is already stoped
else
# 如果不为空则执行
echo kill $tpid
# 关闭进程
kill -9 $tpid
echo "程序已关闭"
fi
}
# 查看状态
status(){
# 获取pid的
pid=$(pgrep -f "controlServer") #$(ps -ef | grep "[m]controlServer" | grep -v grep)
if [ -z "$pid" ]
then
echo "程序不存在"
else
echo $pid
fi
}
# 查看日志信息
log(){
tail -f $HOME/CSPServer.log
}
case $1 in
start)
start
;;
stop)
stop
;;
status)
status
;;
log)
log
;;
restart)
$0 stop
sleep 5
$0 start
;;
*)
echo "只能是{start|stop|log|restart}"
;;
esac
exit 0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12 -1
View File
@@ -8,6 +8,7 @@
"main": "./dist/electron/main.js",
"scripts": {
"build": "node .electron-vue/build.js && electron-builder",
"build:linux": "node .electron-vue/build.js && electron-builder --linux",
"build:dir": "node .electron-vue/build.js && electron-builder --dir",
"build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
"build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
@@ -24,6 +25,16 @@
"build": {
"productName": "soonworkerdisk",
"appId": "com.kashu.soonworkerdisk",
"extraFiles": [
{
"from": "./User Templates",
"to": "."
},
{
"from": "./cardsoonServer",
"to": "."
}
],
"directories": {
"output": "build"
},
@@ -123,4 +134,4 @@
"webpack-hot-middleware": "^2.22.2",
"webpack-merge": "^4.1.3"
}
}
}
+2 -1
View File
@@ -720,7 +720,8 @@ export default {
},
// 获取模板文件列表
getTemplates() {
fs.readdir('User Templates', (err, files) => {
const filePath = path.join(process.cwd(), 'User Templates');
fs.readdir(filePath, (err, files) => {
if (err) {
console.log(err)
} else {
+2 -1
View File
@@ -9,7 +9,7 @@ import 'element-ui/lib/theme-chalk/index.css'
import App from './App'
import router from './router'
import store from './store'
import { accAdd, accSub, accMul, accDiv, filterSize } from './utils'
import { accAdd, accSub, accMul, accDiv, filterSize, runCmd } from './utils'
import i18n from './lang' // internationalization
import './permission' // permission control
@@ -24,6 +24,7 @@ Vue.prototype.$accSub = accSub
Vue.prototype.$accMul = accMul
Vue.prototype.$accDiv = accDiv
Vue.prototype.$filterSize = filterSize
Vue.prototype.$runCmd = runCmd
Vue.use(ElementUI, {
size: Cookies.get('size') || 'medium', // set element-ui default size
+4
View File
@@ -524,6 +524,10 @@ const actions = {
closeWebsocket: () => {
// 关闭
if (websock) websock.close()
},
// 改变工作状态
changeWorkStatus: ({ commit }, data) => {
commit('setData', { name: 'workStatus', data: data })
}
}
+16
View File
@@ -473,4 +473,20 @@ export const filterSize = (size) => {
export const pow1024 = (num) => {
return Math.pow(1024, num)
}
// 执行脚本
const { exec } = require('child_process');
export const runCmd = (cmd) => {
return new Promise((resolve, reject) => {
exec(cmd, (err, stdout, stderr) => {
if (err) {
reject(err)
}
if (stderr) {
reject(stderr)
}
resolve(stdout)
})
})
}
+43 -11
View File
@@ -1,5 +1,8 @@
<template>
<div class="container_box">
<div class="container_box" v-loading="serviceLoading"
:element-loading-text="serviceText"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)">
<!-- 头部 -->
<div class="flex_box flex_row_between top_box">
<div class="flex_box top_left">
@@ -18,7 +21,7 @@
<div class="top_left_line"></div>
<el-tooltip :content="workStatus?'关闭服务':'打开服务'" placement="bottom">
<div class="flex_box flex_row_center top_left_status_box">
<el-switch :disabled="!serviceStatus" @change="serviceChange" class="top_left_status" v-model="workStatus" active-color="#07C160" inactive-color="#aaa"> </el-switch>
<el-switch @change="serviceChange" class="top_left_status" :value="workStatus" active-color="#07C160" inactive-color="#aaa"> </el-switch>
</div>
</el-tooltip>
<div class="flex_box top_left_option">
@@ -299,11 +302,13 @@
let that
let outTimer
let fs = require('fs')
let path = require('path')
import { mapGetters } from 'vuex'
const { app, dialog } = require('@electron/remote')
import UserInfo from '@/components/userInfo/userInfo.vue'
import WorkAdd from '@/components/workAdd/workAdd.vue'
const exePath = process.cwd();
const shPath = path.join(exePath, 'cardsoonServer', 'control.sh')
export default {
name: 'dashboard',
components: { UserInfo, WorkAdd },
@@ -312,6 +317,8 @@ export default {
// 服务状态
isConnect: false,
serviceStatus: false,
serviceLoading: false,
serviceText: '服务关闭中',
// 工作状态
infoStatus: 0,
// 运行选项
@@ -425,6 +432,8 @@ export default {
})
this.taskNum = nums
this.task_list = list
} else {
this.task_list = []
}
},
deep: true,
@@ -516,6 +525,8 @@ export default {
},
mounted() {
that = this
let name = 'ERR_ELECTRON_BUILDER_CANNOT_EXECUTE'
console.log(name.toLowerCase())
},
methods: {
// 服务打开/关闭
@@ -523,16 +534,37 @@ export default {
if (!that.serviceStatus) {
return
}
that.serviceLoading = true
if (e) {
that.store.commit('setData', { name: 'workStatus', data: true })
setTimeout(() => {
that.$store.dispatch('chat/initWebSocket')
}, 500);
that.serviceTextex = '服务启动中'
this.$runCmd(`bash ${shPath} start`).then(res => {
that.$store.dispatch('chat/changeWorkStatus', true)
setTimeout(() => {
that.$store.dispatch('chat/initWebSocket')
that.serviceLoading = false
}, 500);
}).catch(err => {
that.$message({
message: err,
type: 'error'
})
that.serviceLoading = false
})
} else {
that.store.commit('setData', { name: 'workStatus', data: false })
setTimeout(() => {
that.$store.dispatch('chat/closeWebsocket')
}, 500);
that.serviceTextex = '服务关闭中'
this.$runCmd(`bash ${shPath} stop`).then(res => {
that.$store.dispatch('chat/changeWorkStatus', false)
setTimeout(() => {
that.$store.dispatch('chat/closeWebsocket')
that.serviceLoading = false
}, 500);
}).catch(err => {
that.$message({
message: err,
type: 'error'
})
that.serviceLoading = false
})
}
},
// 执行