Skip to content

Go implements simple and easy-to-use windows services

License

Notifications You must be signed in to change notification settings

iGwkang/winservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

winservice

Go implements simple and easy-to-use windows services

How to use

go get "github.com/iGwkang/winservice"

import "github.com/iGwkang/winservice"

var (
	command = flag.String("o", "", "[install/uninstall/start/stop/status]")
)

func main() {
	flag.Parse()

	ws := &winservice.WinService{
		SvcName: "Your Service Name",
		ExecuteFunc: func() {
			// service run function
		},
	}

	if ws.IsWindowsService() {
		ws.Run()
	} else {
		switch *command {
		case "install":
			fmt.Println(ws.InstallService("-o", "test"))
		case "uninstall":
			fmt.Println(ws.UninstallService())
		case "start":
			fmt.Println(ws.StartService())
		case "stop":
			fmt.Println(ws.StopService())
		case "status":
			fmt.Println(ws.Status())
		default:
			ws.ExecuteFunc()
		}
	}
}

About

Go implements simple and easy-to-use windows services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages