You are not logged in.

#1 2013-01-01 13:27:27

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

[solved] emacs daemon systemd unit doesn't start

I found instructions on EmacsWiki for a systemd service file for running the emacs daemon at startup.  It works just fine on my desktop, but for some reason it doesn't work on my laptop.  Here's the service file (/etc/systemd/system/emacs@.service):

[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
Restart=always
User=%1

[Install]
WantedBy=multi-user.target

When I run "systemctl start emacs@<username>", it fails:

$ sudo systemctl status emacs@<username>.service
emacs@<username>.service - Emacs: the extensible, self-documenting text editor
    Loaded: loaded (/etc/system/emacs@.service; enabled)
    Active: failed (Result: start-limit) since Tue, 2013-01-01 09:19:09 AST; 4min 25s ago
    Process: 5621 ExecStart=/user/bin/emacs --daemon (code=exited, status=217/USER)
    CGroup: name=systemd:/system/emacs@.service/<username>

Any ideas why the exact same service file might start on one computer and fail on another?  If I just run "emacs --daemon" manually (or in ~/.xinitrc) it starts just fine.

Thanks.

Last edited by ibrunton (2013-03-06 21:05:17)

Offline

#2 2013-01-01 13:29:51

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,683
Website

Re: [solved] emacs daemon systemd unit doesn't start

You're not actually typing <username> are you?


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#3 2013-01-01 15:03:25

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [solved] emacs daemon systemd unit doesn't start

Trilby wrote:

You're not actually typing <username> are you?

Goodness, no.  I'm putting my actual username there.  I also did run "sudo systemctl enable emacs@<username>".

Offline

#4 2013-01-01 15:43:00

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,683
Website

Re: [solved] emacs daemon systemd unit doesn't start

Good, sorry I had to ask, one never does know.  Beyond that I don't have relevant experience.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#5 2013-01-02 02:21:15

injyuw
Member
Registered: 2012-04-03
Posts: 3

Re: [solved] emacs daemon systemd unit doesn't start

My output:

 
<username>.service - Emacs: the extensible, self-documenting text editor
          Loaded: loaded (/etc/systemd/system/emacs@.service; enabled)
          Active: active (running) since Tue, 2013-01-01 14:07:07 EST; 7min ago
         Process: 4822 ExecStart=/usr/bin/emacs --daemon (code=exited, status=0/SUCCESS)
        Main PID: 4823 (emacs)
          CGroup: name=systemd:/system/emacs@.service/<username>
                  |-4823 /usr/bin/emacs --daemon
                  `-4833 /usr/bin/aspell -a -m -B --encoding=utf-8 --sug-mode=ultra

Have you tried running it with the default .emacs.d & init.el?

Offline

#6 2013-01-02 16:38:07

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [solved] emacs daemon systemd unit doesn't start

injyuw wrote:

My output:

 
<username>.service - Emacs: the extensible, self-documenting text editor
          Loaded: loaded (/etc/systemd/system/emacs@.service; enabled)
          Active: active (running) since Tue, 2013-01-01 14:07:07 EST; 7min ago
         Process: 4822 ExecStart=/usr/bin/emacs --daemon (code=exited, status=0/SUCCESS)
        Main PID: 4823 (emacs)
          CGroup: name=systemd:/system/emacs@.service/<username>
                  |-4823 /usr/bin/emacs --daemon
                  `-4833 /usr/bin/aspell -a -m -B --encoding=utf-8 --sug-mode=ultra

Have you tried running it with the default .emacs.d & init.el?

Same result: failed, status=217/USER.

Offline

#7 2013-01-02 16:53:14

injyuw
Member
Registered: 2012-04-03
Posts: 3

Re: [solved] emacs daemon systemd unit doesn't start

What is the output of ps -aux | grep emacs ?

Offline

#8 2013-01-02 17:22:14

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [solved] emacs daemon systemd unit doesn't start

injyuw wrote:

What is the output of ps -aux | grep emacs ?

$ ps aux | grep emacs
ian        729  0.0  0.0  12112  1108 tty1      S+   13:21   0:00 grep emacs

Offline

#9 2013-01-02 21:46:57

injyuw
Member
Registered: 2012-04-03
Posts: 3

Re: [solved] emacs daemon systemd unit doesn't start

In that case, I can't be much help. I hoped the problem was related to the daemon already running.

While you look for a proper solution, you might be best off using
emacsclient -c -a ""
by binding it to something in your wm/de, or by making an alias for it in your .bashrc. It will start an emacs daemon if one isn't already running, then proceed to create a client window. (or emacsclient -t -a "" for in terminal)

Offline

#10 2013-01-19 10:52:55

eqyiel
Member
From: Australia
Registered: 2011-09-29
Posts: 9

Re: [solved] emacs daemon systemd unit doesn't start

ibrunton wrote:
[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
Restart=always
User=%1

[Install]
WantedBy=multi-user.target

That should be

User=%i

instead of

User=%1

You're welcome.

Offline

Board footer

Powered by FluxBB