mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-06-16 05:55:33 +00:00
wip
This commit is contained in:
parent
12d5e5db03
commit
182bc25343
@ -1,12 +1,13 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
After=casaos-gateway.service
|
After=casaos-gateway.service
|
||||||
ConditionFileNotEmpty=/etc/casaos/casaos.conf
|
ConditionFileNotEmpty=/etc/casaos/casaos.conf
|
||||||
Description=CasaOS Service
|
Description=CasaOS Main Service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/bin/casaos -c /etc/casaos/casaos.conf
|
ExecStart=/usr/bin/casaos -c /etc/casaos/casaos.conf
|
||||||
PIDFile=/var/run/casaos/casaos.pid
|
PIDFile=/var/run/casaos/casaos.pid
|
||||||
Restart=always
|
Restart=always
|
||||||
|
Type=notify
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
1
go.mod
1
go.mod
@ -11,6 +11,7 @@ require (
|
|||||||
github.com/ambelovsky/gosf v0.0.0-20201109201340-237aea4d6109
|
github.com/ambelovsky/gosf v0.0.0-20201109201340-237aea4d6109
|
||||||
github.com/ambelovsky/gosf-socketio v0.0.0-20201109193639-add9d32f8b19 // indirect
|
github.com/ambelovsky/gosf-socketio v0.0.0-20201109193639-add9d32f8b19 // indirect
|
||||||
github.com/containerd/containerd v1.5.7 // indirect
|
github.com/containerd/containerd v1.5.7 // indirect
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
github.com/docker/distribution v2.8.0+incompatible // indirect
|
github.com/docker/distribution v2.8.0+incompatible // indirect
|
||||||
github.com/docker/docker v20.10.7+incompatible
|
github.com/docker/docker v20.10.7+incompatible
|
||||||
|
24
main.go
24
main.go
@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/IceWhaleTech/CasaOS/route"
|
"github.com/IceWhaleTech/CasaOS/route"
|
||||||
"github.com/IceWhaleTech/CasaOS/service"
|
"github.com/IceWhaleTech/CasaOS/service"
|
||||||
"github.com/IceWhaleTech/CasaOS/types"
|
"github.com/IceWhaleTech/CasaOS/types"
|
||||||
|
"github.com/coreos/go-systemd/daemon"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"github.com/robfig/cron"
|
"github.com/robfig/cron"
|
||||||
@ -135,14 +136,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// s := &http.Server{
|
|
||||||
// Addr: listener.Addr().String(), //fmt.Sprintf(":%v", config.ServerInfo.HttpPort),
|
|
||||||
// Handler: r,
|
|
||||||
// ReadTimeout: 60 * time.Second,
|
|
||||||
// WriteTimeout: 60 * time.Second,
|
|
||||||
// MaxHeaderBytes: 1 << 20,
|
|
||||||
// }
|
|
||||||
// s.ListenAndServe()
|
|
||||||
urlFilePath := filepath.Join(config.CommonInfo.RuntimePath, "casaos.url")
|
urlFilePath := filepath.Join(config.CommonInfo.RuntimePath, "casaos.url")
|
||||||
err = file.CreateFileAndWriteContent(urlFilePath, "http://"+listener.Addr().String())
|
err = file.CreateFileAndWriteContent(urlFilePath, "http://"+listener.Addr().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -152,7 +145,20 @@ func main() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = http.Serve(listener, r)
|
if supported, err := daemon.SdNotify(false, daemon.SdNotifyReady); err != nil {
|
||||||
|
loger.Error("Failed to notify systemd that casaos main service is ready", zap.Any("error", err))
|
||||||
|
} else if supported {
|
||||||
|
loger.Info("Notified systemd that casaos main service is ready")
|
||||||
|
} else {
|
||||||
|
loger.Info("This process is not running as a systemd service.")
|
||||||
|
}
|
||||||
|
|
||||||
|
s := &http.Server{
|
||||||
|
Handler: r,
|
||||||
|
ReadHeaderTimeout: 5 * time.Second, // fix G112: Potential slowloris attack (see https://github.com/securego/gosec)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.Serve(listener) // not using http.serve() to fix G114: Use of net/http serve function that has no support for setting timeouts (see https://github.com/securego/gosec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
/*
|
/*@Author: LinkLeong link@icewhale.com
|
||||||
* @Author: LinkLeong link@icewhale.com
|
*@Date: 2022-02-17 18:53:22
|
||||||
* @Date: 2022-02-17 18:53:22
|
*@LastEditors: LinkLeong
|
||||||
* @LastEditors: LinkLeong
|
*@LastEditTime: 2022-09-06 14:27:42
|
||||||
* @LastEditTime: 2022-09-06 14:27:42
|
*@FilePath: /CasaOS/types/system.go
|
||||||
* @FilePath: /CasaOS/types/system.go
|
*@Description:
|
||||||
* @Description:
|
*@Website: https://www.casaos.io
|
||||||
* @Website: https://www.casaos.io
|
*Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
|
||||||
*/
|
*/
|
||||||
package types
|
package types
|
||||||
|
|
||||||
const CURRENTVERSION = "0.3.6"
|
const CURRENTVERSION = "0.3.7"
|
||||||
|
|
||||||
const BODY = " "
|
const BODY = " "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user