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

MacOS: incorrect status when calling Service.Status without root privilege. #400

Open
cuonglm opened this issue Jul 17, 2024 · 0 comments
Open

Comments

@cuonglm
Copy link

cuonglm commented Jul 17, 2024

I wrote a service named ctrld, after installing, verifying that the service is running:

$ sudo ./ctrld status
Jul 17 15:27:34.000 NTC Service is running
$ ./ctrld status
Jul 17 15:27:27.000 NTC Service is stopped

Querying the status using launchctl confirms this:

$ sudo launchctl list ctrld
{
	"StandardOutPath" = "/usr/local/var/log/ctrld.out.log";
	"LimitLoadToSessionType" = "System";
	"StandardErrorPath" = "/usr/local/var/log/ctrld.err.log";
	"Label" = "ctrld";
	"OnDemand" = false;
	"LastExitStatus" = 0;
	"PID" = 11444;
	"Program" = "/Users/cuonglm/ctrld";
	"ProgramArguments" = (
		"/Users/cuonglm/ctrld";
		"run";
		"--cd=p2";
		"--iface=auto";
		"--homedir=/etc/controld";
		"--config=/etc/controld/ctrld.toml";
	);
};
$ launchctl list ctrld
Could not find service "ctrld" in domain for port

The problem seems to be this line:

if !strings.Contains(err.Error(), "failed with stderr") {

Specifically, this condition !strings.Contains(err.Error(), "failed with stderr") is the culprit.

@cuonglm cuonglm changed the title Incorrect status when calling Service.Status without root privilege. MacOS: incorrect status when calling Service.Status without root privilege. Jul 17, 2024
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