add install script
This commit is contained in:
parent
b39d4a0ea8
commit
f6f31e56c4
2
Makefile
2
Makefile
|
@ -6,6 +6,8 @@ build:
|
||||||
go build -o ${BINARY_NAME}
|
go build -o ${BINARY_NAME}
|
||||||
cp config.json target/
|
cp config.json target/
|
||||||
cp -r adminui target/
|
cp -r adminui target/
|
||||||
|
cp gohttpd.service target/
|
||||||
|
cp install.sh target/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
go clean
|
go clean
|
||||||
|
|
34
config.json
34
config.json
|
@ -45,87 +45,87 @@
|
||||||
"paths":[
|
"paths":[
|
||||||
{
|
{
|
||||||
"path": "/",
|
"path": "/",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://localhost:4200"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/ssologin",
|
"path" : "/ssologin",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/themes",
|
"path" : "/themes",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/security/login",
|
"path" : "/security/login",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/security/logout",
|
"path" : "/security/logout",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/v1/relational/assets",
|
"path" : "/v1/relational/assets",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/platform/version",
|
"path" : "/platform/version",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/v1/patrolrecords",
|
"path" : "/v1/patrolrecords",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/v1/standingbook",
|
"path" : "/v1/standingbook",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/v1/resource",
|
"path" : "/v1/resource",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/v1/config",
|
"path" : "/v1/config",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/v1/workflow",
|
"path" : "/v1/workflow",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path":"/token/check",
|
"path":"/token/check",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/v1/messages",
|
"path" : "/v1/messages",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/cloudops-state/",
|
"path" : "/cloudops-state/",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path":"/socket.io/",
|
"path":"/socket.io/",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":["HostSchemas $target"]
|
"directives":["HostSchemas $target"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/thing",
|
"path" : "/thing",
|
||||||
"upstreams": ["http://192.168.12.174:9880"],
|
"upstreams": ["http://192.168.12.157:9880"],
|
||||||
"directives":[
|
"directives":[
|
||||||
"HostSchemas $target",
|
"HostSchemas $target",
|
||||||
"HeaderOrigin",
|
"HeaderOrigin",
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=GoHTTPD Web Server
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/gohttpd
|
||||||
|
WorkingDirectory=/usr/local/gohttpd
|
||||||
|
Environment="GoHTTPD_Home=/usr/local/gohttpd"
|
||||||
|
Environment="_go_daemon=g_daemon"
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
which gohttpd
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "gohttpd is already installed."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#获取当前脚本所在目录
|
||||||
|
scriptPath=$( cd `dirname $0` && pwd )
|
||||||
|
|
||||||
|
# 创建目录/usr/local/gohttpd
|
||||||
|
mkdir -p /usr/local/gohttpd
|
||||||
|
# 复制文件到scriptPath下的所有文件到/usr/local/gohttpd
|
||||||
|
cp -r $scriptPath/* /usr/local/gohttpd/
|
||||||
|
# link /usr/local/gohttpd/gohttpd to /usr/local/bin/gohttpd
|
||||||
|
ln -s /usr/local/gohttpd/gohttpd /usr/local/bin/gohttpd
|
||||||
|
|
||||||
|
# 安装gohttpd.service文件
|
||||||
|
cp $scriptPath/gohttpd.service /etc/systemd/system/
|
||||||
|
# 启动服务
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable gohttpd.service
|
||||||
|
systemctl start gohttpd.service
|
||||||
|
|
||||||
|
echo "gohttpd installed successfully."
|
|
@ -6,12 +6,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetExecDir() string {
|
func GetExecDir() string {
|
||||||
|
if os.Getenv("GoHTTPD_Home") != "" {
|
||||||
|
return os.Getenv("GoHTTPD_Home")
|
||||||
|
}
|
||||||
execPath, err := os.Executable()
|
execPath, err := os.Executable()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return filepath.Dir(execPath)
|
rpath, err := filepath.EvalSymlinks(execPath)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
rpath, _ = filepath.Abs(rpath)
|
||||||
|
return filepath.Dir(rpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NormalizePath(path string) string {
|
func NormalizePath(path string) string {
|
||||||
|
|
Loading…
Reference in New Issue