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

Managing a "user unit file" via dbus, how? #436

Open
shadyabhi opened this issue Mar 28, 2024 · 0 comments
Open

Managing a "user unit file" via dbus, how? #436

shadyabhi opened this issue Mar 28, 2024 · 0 comments

Comments

@shadyabhi
Copy link

shadyabhi commented Mar 28, 2024

I'm puzzled on how to manage a "user service" via this package. Help is greatly appreciated.

func TestGithubIssue(t *testing.T) {
	ctx := context.Background()
	dbusConn, err := dbus.NewUserConnectionContext(ctx)
	require.NoError(t, err, "creating new dbus connection")
	defer dbusConn.Close()

	spew.Dump(dbusConn.GetUnitPropertiesContext(ctx, "longrunning.service"))
}

Outputs:-

=== RUN   TestGithubIssue
(map[string]interface {}) <nil>
(dbus.Error) Process org.freedesktop.systemd1 exited with status 1

However, from CLI, I'm able to get the status of service.

➤ systemctl --user status longrunning.service
○ longrunning.service - longrunning
     Loaded: loaded (/home/arastogi/.config/systemd/user/longrunning.service; static)
     Active: inactive (dead)

I was able to find this previous Github issue, but it didn't really have an answer. #424 (comment)

I tried sending dbus messages directly, I get the same error.

➤ eval `dbus-launch --auto-syntax`

>>>  0s elapsed...
➜ $?=0 @arastogi-ld1 bincontrol/systemd (master↑1|✚3…) [5:53:26]
➤ dbus-send --print-reply --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager.StartUnit string:'[email protected]' string:'replace'
Error org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1

My research so far below:-

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