Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for service install on systemd #159

Open
annamel opened this issue Dec 29, 2018 · 0 comments
Open

Checking for service install on systemd #159

annamel opened this issue Dec 29, 2018 · 0 comments

Comments

@annamel
Copy link

annamel commented Dec 29, 2018

One of the common ways to check whether the service is installed is getting its status and checking for error code

	_, err = s.Status()
	return err != service.ErrNotInstalled

Unfortunately, for systemd init system such an approach doesn't work.
Status function of Kardianos Service project raises "systemctl is-active" call https://github.com/kardianos/service/blob/master/service_systemd_linux.go#L198
systemctl is-active would return "inactive" status for both stopped and non-existent service. So if the service has never been installed on the machine, Kardianos service.Status() would return Stopped.

It looks like

  • either Status() of Kardianos.Service in the case of SystemD should rely on "systemctl status" or "systemctl list-units"
  • or there should be some other way in Kardianos to check whether the service is installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant