Open
Description
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:-
- I see that its mentioned that user services are not on system bus: https://systemd-devel.freedesktop.narkive.com/Noey9TiS/how-to-call-dbus-listunits-for-user-units
- It appears systemd uses a private bus, so maybe, normal dbus APIs don't work? https://lists.freedesktop.org/archives/systemd-devel/2015-February/028361.html
Metadata
Assignees
Labels
No labels