This commit is contained in:
Aleksey Khorev
2021-08-11 22:36:12 +03:00
parent e4a4b3bf86
commit 9e6144d9b5
5 changed files with 109 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
package main
import (
"log"
"sync"
"github.com/judwhite/go-svc"
)
// program implements svc.Service
type program struct {
wg sync.WaitGroup
quit chan struct{}
}
func main() {
prg := &program{}
// Call svc.Run to start your program/service.
if err := svc.Run(prg); err != nil {
log.Fatal(err)
}
}
func (p *program) Init(env svc.Environment) error {
log.Printf("is win service? %v\n", env.IsWindowsService())
return nil
}
func (p *program) Start() error {
// The Start method must not block, or Windows may assume your service failed
// to start. Launch a Goroutine here to do something interesting/blocking.
p.quit = make(chan struct{})
p.wg.Add(1)
go func() {
log.Println("Starting...")
<-p.quit
log.Println("Quit signal received...")
p.wg.Done()
}()
return nil
}
func (p *program) Stop() error {
// The Stop method is invoked by stopping the Windows service, or by pressing Ctrl+C on the console.
// This method may block, but it's a good idea to finish quickly or your process may be killed by
// Windows during a shutdown/reboot. As a general rule you shouldn't rely on graceful shutdown.
log.Println("Stopping...")
close(p.quit)
p.wg.Wait()
log.Println("Stopped.")
return nil
}
+7
View File
@@ -0,0 +1,7 @@
module github.com/khorevaa/ras-service
go 1.17
require github.com/judwhite/go-svc v1.2.1
require golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
+4
View File
@@ -0,0 +1,4 @@
github.com/judwhite/go-svc v1.2.1 h1:a7fsJzYUa33sfDJRF2N/WXhA+LonCEEY8BJb1tuS5tA=
github.com/judwhite/go-svc v1.2.1/go.mod h1:mo/P2JNX8C07ywpP9YtO2gnBgnUiFTHqtsZekJrUuTk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+22
View File
@@ -0,0 +1,22 @@
@startuml
'https://plantuml.com/use-case-diagram
:Main Admin: as Admin
(Use the application) as (Use)
User -> (Start)
User --> (Use)
Admin ---> (Use)
note right of Admin : This is an example.
note right of (Use)
A note can also
be on several lines
end note
note "This note is connected\nto several objects." as N2
(Start) .. N2
N2 .. (Use)
@enduml
+19
View File
@@ -0,0 +1,19 @@
@startmindmap
'https://plantuml.com/mindmap-diagram
caption Microservice concept
title Control RAS
* <&globe>Service
** RAS
*** Запуск/перезапуск службы RAS
*** Подключение к удаленной службе RAS
*** Мониторинг работы службы RAS
*** Подключение к мастер-ноде для регистрации\nи удаленного управления
** Client
*** RESTAPI
*** gRPC
center footer Концепция работы
@endmindmap