You are not logged in.

#1 2012-12-13 05:36:54

sprmnmike17
Member
Registered: 2012-12-13
Posts: 4

Having issues with starting systemd as user.

I am trying to process through the steps for configuring SABnzbd for local user configs but after rebooting from completing the steps here. I double checked my work but I still get an error when I am trying to start the service as me.

This is what I am getting:

$ systemctl --user
Failed to issue method call: Process /bin/false exited with status 1

Offline

#2 2012-12-14 17:19:27

centos
Member
From: Ostrava, Czech Republic
Registered: 2009-01-09
Posts: 65

Re: Having issues with starting systemd as user.

I have the same problem. Just want to get mpdscribble working with systemd, so I want to start mpd as user as mentioned here https://wiki.archlinux.org/index.php/Mp … th_systemd

% systemctl --user enable mpd                      
zsh: correct 'mpd' to '.mpd' [nyae]? n
Failed to issue method call: Process /bin/false exited with status 1

Offline

#3 2012-12-19 03:55:06

Beelzebud
Member
From: Illinois, U.S.
Registered: 2010-07-16
Posts: 154

Re: Having issues with starting systemd as user.

I just reinstalled Arch after not having it for a few months, and was just starting to like systemd when I ran in to this.   I"m trying to do the exact same thing (set up mpd and sabnzbd both as a user instance), and I can't get it to work correctly.   I get the same error you are getting.

Last edited by Beelzebud (2012-12-19 04:03:00)

Offline

#4 2012-12-19 19:26:08

sprmnmike17
Member
Registered: 2012-12-13
Posts: 4

Re: Having issues with starting systemd as user.

Just sucks we can't get anyone to help, I have always loved Linux and Arch specifically because of the great documentation and support but this is getting frustrating.

Offline

#5 2012-12-19 20:54:53

Beelzebud
Member
From: Illinois, U.S.
Registered: 2010-07-16
Posts: 154

Re: Having issues with starting systemd as user.

Yeah, I went from starting to like SystemD on Saturday, to pretty much hating it at this point.   It's like a black box.   At least with scripts I could take a look and see if anything was wrong.   Now I'm at the mercy of a black box, and there is no clear way to diagnose this problem.    I follow the instructions on the wiki to the letter and it just doesn't work.  (That's a whole other can of worms.   Large swathes of the wiki are now useless because they refer to the old init system) 

The logs are vague, documentation is thin, and frankly this is such a common thing to set up, that I can't even believe it's an issue.   I never thought running something as a user could get so complicated.   As a sloppy workaround, I just started using KDE's autostart folder the old fashioned way.   I'll give it another go in a few months, but it's clear to me that systemd isn't really ready for desktop usage.   For now it's back to the boring sanity of Slackware.

Last edited by Beelzebud (2012-12-19 20:56:08)

Offline

#6 2012-12-19 22:34:11

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,146

Re: Having issues with starting systemd as user.

I am still new to systemd (so my answer may contain inaccuracies) but to run systemctl as user, you have also to run a systemd daemon as a user. The error

Failed to issue method call: Process /bin/false exited with status 1

is probably due to the fact that you have not started a systemd daemon. I think the truly proper way to use systemd as user is to have this sole unique line in your ~/.xinitrc (or whatever file you use to start the X session):

#! /bin/sh
exec systemd

and have systemd properly configured to start your session and whatever you need to start. It may be possible to start the systemd daemon in the background and still start the session or additional services outside of systemd. If you have started a systemd daemon, you also need to have ~/.config/systemd/user/ or /etc/systemd/user/ properly configured in order to start services as a user.

I do not know how mpd is packaged but it might be easier to not use systemd as a user and just to start the daemon directly.

Last edited by olive (2012-12-19 22:47:02)

Offline

#7 2012-12-19 22:35:54

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Having issues with starting systemd as user.

Here's a quick example for mpd...note that this will run as your user, but it's not using the 'systemd --user' commands from the wiki. TBH I haven't tried it that way before. When I get a chance, I'll give it a try. At least this way keeps your .xinitrc that much less cluttered smile

/etc/systemd/system/mpd@.service

[Unit]
Description=Music Player Daemon
After=sound.target

[Service]
User=%I
ExecStart=/usr/bin/mpd %h/.config/mpd/mpd.conf --no-daemon
ExecStop=/usr/bin/mpd --kill

[Install]
WantedBy=multi-user.target
# systemctl enable mpd@<username>
# systemctl start mpd@<username>  (to start immediately...otherwise it will autostart on your next reboot)

Scott

Last edited by firecat53 (2012-12-19 22:37:00)

Offline

#8 2012-12-19 22:39:55

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,146

Re: Having issues with starting systemd as user.

firecat53 wrote:

/etc/systemd/system

Services in /etc/systemd/system are not supposed to be started as a user. You need to have a proper file in
/etc/systemd/user/ or ~/.config/systemd/user/  for that (and have a systemd daemon running as a user). I still do not know exactly how to write systemd file but I don't believe that to copy the system service file in the user directory will work. I do not know mpd but maybe it is easier to start it by hand:

/usr/bin/mpd --some --options &

Last edited by olive (2012-12-19 22:48:35)

Offline

#9 2012-12-19 23:00:32

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Having issues with starting systemd as user.

olive wrote:

Services in /etc/systemd/system are not supposed to be started as a user.

You are correct...however, you _can_ run a user service as that user by including the 'User=xxx' directive in the service file. You just have to start/stop it as root. I showed the 'systemctl enable/start' commands being started as root. Like I said, I still haven't played with systemd services as user yet smile  The method I described above does work...I've been using it for some time now. Since these services are autostarted on boot, I rarely ever have to manually start them anyways.

Scott

Edit: browsing around a bit more...you aren't the first ones to have this issue. There may be some systemd per-user session issues that aren't yet resolved.

Last edited by firecat53 (2012-12-19 23:08:38)

Offline

#10 2012-12-20 00:13:14

centos
Member
From: Ostrava, Czech Republic
Registered: 2009-01-09
Posts: 65

Re: Having issues with starting systemd as user.

olive: I switched to systemd few weeks ago, so not having it started is not that problem.
I have this in .xinitrc file

..
systemd --user &
exec gnome-session
.. 

https://wiki.archlinux.org/index.php/Systemd/User
Don't understand this line:

A user simply has to add systemd --user as a program to be started by their desktop environment. 

Is that already solved by my .xinitrc?

Offline

#11 2012-12-20 02:44:36

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Having issues with starting systemd as user.

I was able to get mpd running as a 'systemd --user' process. I already use systemd, so all I had to do was:
1. systemd --user &
2. Make sure that this returns 'Active=Yes'

loginctl --no-pager show-session $XDG_SESSION_ID | grep Active

3. create the ~/.config/systemd/user directories
4. ~/.config/systemd/user/mpd.service

[Unit]
Description=Music Player Daemon

[Service]
ExecStart=/usr/bin/mpd %h/.config/mpd/mpd.conf --no-daemon
ExecStop=/usr/bin/mpd --kill

[Install]
WantedBy=default.target

5. 'systemctl --user enable mpd.service'
6. 'systemctl --user start mpd.service'

That's it. I can see the utility of using this method when, for example, you may have other users without root access. However for me personally on a single-user machine I'll probably continue just using root systemd service files for now so all my logs/files are in one place.

Scott

Offline

#12 2012-12-20 08:24:41

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,146

Re: Having issues with starting systemd as user.

centos wrote:
systemd --user &
exec gnome-session


[url]https://wiki.archlinux.org/index.php/Systemd/User[/url]
Don't understand this line:

A user simply has to add systemd --user as a program to be started by their desktop environment. 

Is that already solved by my .xinitrc?

Yes, you have followed the wiki on this point. But I think the wiki is in a few place misleading. First the --user argument is completely unnecessary (systemd detect automatically that you start it as a user). I also think that it is best to have exec systemd as the sole line in your ~/.xinitrc and have systemd configured to start your gnome-session (this would allow, amoung other to exit the session with systemd). Third have you the correct files in /etc/systemd/system or ~/.config/systemd/user/

Offline

#13 2012-12-20 12:26:24

centos
Member
From: Ostrava, Czech Republic
Registered: 2009-01-09
Posts: 65

Re: Having issues with starting systemd as user.

firecat53 wrote:

I was able to get mpd running as a 'systemd --user' process. I already use systemd, so all I had to do was:

Scott

Can you pls post your .xinitrc? I followed your steps and still getting this error.

olive wrote:

exec systemd as the sole line in your ~/.xinitrc and have systemd configured to start your gnome-session

My .xinitrc:

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

exec systemd


conky

(Don't know if that startx is neccesary, will test later.)

MPD itself is running fine as system daemon, I just thought it's needed to change it to user in order to get mpdscribble working https://wiki.archlinux.org/index.php/Mu … pdscribble

Offline

#14 2012-12-20 17:24:07

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Having issues with starting systemd as user.

centos wrote:

Can you pls post your .xinitrc? I followed your steps and still getting this error.

I didn't use .xinitrc...I just got MPD running to test it first. You should also do that before adding it to .xinitrc for autostarting. Did you also stop your system MPD daemon first?

We also need to see the exact steps you took, what service file you're using and the exact error messages you received before we can help!

centos wrote:

MPD itself is running fine as system daemon, I just thought it's needed to change it to user in order to get mpdscribble working https://wiki.archlinux.org/index.php/Mu … pdscribble

You can have a service run as any user in a root-owned service file by adding the 'User=' directive and making sure things such as PID's and log file paths are writeable by that user. Just like in the first example I gave in this thread. To my knowledge, there's no _requirement_ to run something with 'systemd --user'...unless you have multiple users that need access to manage their own services.

Scott

Offline

#15 2012-12-20 22:09:30

centos
Member
From: Ostrava, Czech Republic
Registered: 2009-01-09
Posts: 65

Re: Having issues with starting systemd as user.

MPD is not running:

% ps -ef | grep mpd                                                               !1004
honza     2625  1629  0 22:41 pts/0    00:00:00 grep mpd

Then I made that /etc/systemd/system/mpd@.service file, same as yours.

 % sudo systemctl enable mpd@honza                                                 !1006
ln -s '/etc/systemd/system/mpd@.service' '/etc/systemd/system/multi-user.target.wants/mpd@honza.service'

% sudo systemctl start mpd@honza

This seems OK, but MPD is not running.

% systemctl list-units | grep 'mpd'                                               !1009
mpd@honza.service           loaded failed failed    Music Player Daemon
mpd@multi-user.service      loaded failed failed    Music Player Daemon

That was your first example. The second one:

honza@inkognito ~
  % systemctl list-units | grep 'mpd'                                              

honza@inkognito ~
  % systemd --user &                                                              
[1] 1703

honza@inkognito ~
  % mpd.service: main process exited, code=exited, status=1/FAILURE              
mpd.service: control process exited, code=exited status=1
Unit mpd.service entered failed state

I used the same service file.
But at least the "systemd --user &" line in terminal helped a little, because I'm not getting that first error anymore.

% systemctl --user status mpd              
mpd.service - Music Player Daemon
	  Loaded: loaded (/home/honza/.config/systemd/user/mpd.service; enabled)
	  Active: failed (Result: exit-code) since Čt, 2012-12-20 22:59:14 CET; 2min 37s ago
	 Process: 1710 ExecStop=/usr/bin/mpd --kill (code=exited, status=1/FAILURE)
	 Process: 1708 ExecStart=/usr/bin/mpd %h/.config/mpd/mpd.conf --no-daemon (code=exited, status=1/FAILURE)
	  CGroup: name=systemd:/user/honza/2/systemd-1703/mpd.service

So.. something's wrong.
Thank you for your help, btw.

Offline

#16 2012-12-21 00:55:54

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Having issues with starting systemd as user.

1. What does journalctl tell you for the first case (mpd@honza)? There should be a specific error message as to why mpd didn't start.
2. Silly question, but you do have the file ~/.config/mpd/mpd.conf, and with the correct permissions, right?
3. What is this line from? 'mpd@multi-user.service      loaded failed failed    Music Player Daemon'  Do you have another mpd instance enabled? Make sure you only have the one instance in /etc/systemd/system/multi-user.target.wants.
4. Make sure you're just working on one case at a time...either root-controlled or user-controlled.
5. I don't see anywhere where you did 'systemctl enable mpd.service' for the user-controlled case. You should get a link created in ~/.config/mpd/default (I think), similar to the link that gets created in /etc/systemd/system/multi-user.target.wants for the root-controlled case.

Scott

Offline

#17 2012-12-21 05:25:57

sprmnmike17
Member
Registered: 2012-12-13
Posts: 4

Re: Having issues with starting systemd as user.

Ok I feel a little stupid but was able to figure out my issue to run systemd as user you have to add this to your ~./xinitrc file

exec systemd --user &

Forgetting the exec makes it not run I guess, so after that SABnzbd still wouldn't start it let me do enable but wouldn't start so I went back to the instructions and noticed that my file /etc/conf.d/sabnzbd_systemd was actually named /etc/conf.d/sabnzbd_systemd.pacsave so it wasn't seeing it. So then I ran this:

$ sudo cp /etc/conf.d/sabnzbd_systemd.pacsave /etc/conf.d/sabnzbd_systemd

Then I disabled the service and re-enabled and started like this and it worked like a charm:

$ systemctl --user disable sabnzbd
$ systemctl --user enable sabnzbd
$ systemctl --user start sabnzbd

Last edited by sprmnmike17 (2012-12-21 05:26:45)

Offline

#18 2012-12-21 10:29:03

centos
Member
From: Ostrava, Czech Republic
Registered: 2009-01-09
Posts: 65

Re: Having issues with starting systemd as user.

firecat53 wrote:

1. What does journalctl tell you for the first case (mpd@honza)? There should be a specific error message as to why mpd didn't start.

I repeated all the steps today, it still didn't start and journalctl tells me nothing. but...

firecat53 wrote:

2. Silly question, but you do have the file ~/.config/mpd/mpd.conf, and with the correct permissions, right?

... That's embarrasing. Journalctl told me that it couldn't read config file and pid file. Pid file wasn't even there, so I created it. And I don't have mpd in .config, but in
~/.mpd/mpd.conf, so that was the reason.
Just didn't noticed it in your example.

firecat53 wrote:

3. What is this line from? 'mpd@multi-user.service      loaded failed failed    Music Player Daemon'  Do you have another mpd instance enabled? Make sure you only have the one instance in /etc/systemd/system/multi-user.target.wants.

I think it somehow started automatically. Don't know why. But on today's attempt only mpd@honza was there.


So I'm happy that at least second example works fine now. Now it's time to get mpdscribble finally working smile
Thanks.

By the way, if the system has been switched to systemd, isn't there possibility of "exec systemd --user &" in .xinitrc causing some mess or maybe redundancy of some kind?


EDIT: I can't get it to work automatically via .xinitrc. I tried:
"exec systemd --user &"
"systemd --user &"
and "systemd --user &
exec"

From terminal it runs fine. So I think that xinitrc file is not even working.

Last edited by centos (2012-12-21 12:21:29)

Offline

#19 2012-12-21 16:40:22

centos
Member
From: Ostrava, Czech Republic
Registered: 2009-01-09
Posts: 65

Re: Having issues with starting systemd as user.

I think I've finally got it working.
This thread helped: https://bbs.archlinux.org/viewtopic.php?pid=1207675

So what I did was:

1) install xorg-launch-helper and user-session-units from AUR ( https://wiki.archlinux.org/index.php?ti … ur_Session )
2) add to /etc/pam.d/login

 session    required     pam_systemd.so 

3) 'ln -s /usr/lib/systemd/system/user-session@.service /etc/systemd/system/multi-user.target.wants/user-session@LOGIN.service'

Offline

#20 2012-12-21 16:48:41

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 3,742

Re: Having issues with starting systemd as user.


Evil #archlinux@freenode channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#21 2013-03-22 00:20:56

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: Having issues with starting systemd as user.

This isn't working but I'd thought I'd share my process in case anyone like to see it, as I think its close.  This is for running MPD and login and then GNOME:

Create xsession to run systemd (/usr/share/xsessions/gnome-systemd.desktop):

[Desktop Entry]
Type=Application
Name=systemd
Comment=Runs 'systemd' as a user instance.
Exec=/usr/lib/systemd/systemd --user

Add files necessary for systemd userspace support (makes systemd --user & able to start services up when loaded):

pm i user-session-units
sudo ln -s /usr/lib/systemd/system/user-session@.service /etc/systemd/system/multi-user.target.wants/user-session@USERNAME.service
systemd --user & # start systemd userspace instance
systemctl --user enable gnome-session  # suspect the problem is here

Add a local service file (~/.config/systemd/user/mpd.service):

[Unit]
Description=Music Player Daemon

[Service]
ExecStart=/usr/bin/mpd --no-daemon
ExecStop= /usr/bin/mpd --kill

[Install]
WantedBy=default.target

Enable mpd:

systemctl --user enable mpd

Quit local systemd and test:

pkill -u $UID -x systemd

Add session    required     pam_systemd.so to /etc/pam.d/login.
Login/logout.

Expected:
MPD to launch, then gnome-session but hung at Login screen.
Not sure what happened but typing systemctl --user start gnome-session from console it did start after that.


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#22 2013-04-09 14:56:11

Archaicus
Member
Registered: 2013-04-09
Posts: 4

Re: Having issues with starting systemd as user.

Hi !

I saw the mpd wiki page was changed based on this thread. It is mentioned that "Autostart with systemd" is still in development. But I don't understand why ? The setup is divided in two: the expected and the current one. What are the differences between both of them? The only difference I noticed is the file to launch systemd as user. One method uses ~/.profile as the other one use ~/.xinitrc. What is better between launching mpd as user deamon and  lauching mpd through systemd ?

And last question... Why is the local method in the sabnzbd wiki page outdated ? (it works like a charm...)

Thanks!

Offline

#23 2013-06-26 06:59:35

andmolna
Member
Registered: 2013-06-26
Posts: 1

Re: Having issues with starting systemd as user.

Hi! I had the same issue. It was solved by replacing

exec systemd --user &

with

/usr/lib/systemd/systemd --user &

in my .xinitrc. After this I get no more messages like

Failed to issue method call: Process /bin/false exited with status 1

when trying to  run systemctl as user.

Offline

Board footer

Powered by FluxBB