1 Star 0 Fork 206

bulu_2019/WuKongIM

forked from WuKongDev/WuKongIM 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
stop.go 771 Bytes
一键复制 编辑 原始数据 按行查看 历史
tangtaoit 提交于 8个月前 . refactor: backend services
package cmd
import (
"fmt"
"os"
"path"
"github.com/WuKongIM/WuKongIM/pkg/wkutil"
"github.com/spf13/cobra"
)
type stopCMD struct {
ctx *WuKongIMContext
}
func newStopCMD(ctx *WuKongIMContext) *stopCMD {
return &stopCMD{
ctx: ctx,
}
}
func (s *stopCMD) CMD() *cobra.Command {
cmd := &cobra.Command{
Use: "stop",
Short: "stop the WuKongIM server",
RunE: s.run,
}
return cmd
}
func (s *stopCMD) run(cmd *cobra.Command, args []string) error {
strb, _ := os.ReadFile(path.Join(".", pidfile))
pid := wkutil.ParseInt(string(strb))
process, err := os.FindProcess(pid)
if err != nil {
return err
}
if process == nil {
return nil
}
err = process.Kill()
if err != nil {
return err
}
fmt.Println("WuKongIM server stopped")
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bulu2020/WuKongIM.git
git@gitee.com:bulu2020/WuKongIM.git
bulu2020
WuKongIM
WuKongIM
main

搜索帮助