自动更新管控端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

66 lines
1.4 KiB

package main
import (
"fmt"
"fss/config"
"fss/core"
"log"
"net/http"
"os"
)
// 启动web服务
func startWeb() {
//创建一个文件服务器,会去www目录下找index.html
fileServer := http.FileServer(http.Dir("./fsw"))
// 将 "/" 路径映射到文件服务器
http.Handle("/", fileServer)
//扫描指定的目录
http.HandleFunc("/sc", core.SerInfo)
// 数据库基础信息
http.HandleFunc("/bs", core.BfsInfo)
// 文件接收
http.HandleFunc("/rc", core.ReceiveHandler)
// 发送zip文件
http.HandleFunc("/sendZip", core.SendZip)
fmt.Printf("Starting server at port 9099\n")
// 启动HTTP服务器并监听端口 80,如果出现错误,则打印错误信息并退出
if err := http.ListenAndServe(":9099", nil); err != nil {
log.Fatal(err)
}
}
// 主函数
func main() {
// 获取ip地址
lcip, err := config.GetLocalIP()
if err != nil {
fmt.Printf("get server ip faild %v", err)
}
// 判断输入
args := os.Args
if args == nil || len(args) < 2 {
fmt.Printf("Usage: ./fss -t /home/\n")
os.Exit(1)
}
config.G.LocalIP = lcip
//
flag := args[1]
if flag == "-t" {
wkdir := args[2]
// 赋值给全局
config.G.FilePath = wkdir
} else {
//
curdir, err := os.Getwd()
if err != nil {
fmt.Printf("initlizer faild %v", err)
}
// current work directory
config.G.FilePath = curdir
}
// web service
startWeb()
}