Wizard
Wizard

Reputation: 22103

systemctl invoke an emacs server

Upon reading Emacs Server - GNU Emacs Manual,
it states 3 methods to invoke emacs server,

  1. type M-x server-start within a running frame
  2. emacs --daemon

and third

If your operating system uses systemd to manage startup, you can automatically start Emacs in daemon mode when you login using the supplied systemd unit file. To activate this:
systemctl --user enable emacs

(If your Emacs was installed into a non-standard location, you may need to copy the emacs.service file to a standard directory such as ~/.config/systemd/user/.)

The emacs is the the standard directory

$ which emacs
/usr/bin/emacs

Run

$ systemctl --user enable emacs
Created symlink /home/me.config/systemd/user/default.target.wants/emacs.service → /usr/lib/systemd/user/emacs.service.

Check that no server running after the above operation

 ps -ef |grep emacs | sed "s/$USER/me/g"
me   32251  3018  0 19:21 pts/2    00:00:00 grep --color=auto emacs

Run ystemctl --user enable emacs multiple times, but found no server running .

start an emacs instances

$ ps -ef |grep emacs | sed "s/$USER/me/g"
me   32336  3018 47 19:22 pts/2    00:00:03 emacs
me   32379  3018  0 19:22 pts/2    00:00:00 grep --color=auto emacs

Still does not find a server running.

What's the problem with my usage of systemctl ?

Upvotes: 0

Views: 441

Answers (1)

Michał Politowski
Michał Politowski

Reputation: 4385

systemctl enable does not start anything, it only configures things for the future, as described in the systemctl manpage:

Enabling units should not be confused with starting (activating) units, as done by the start command. Enabling and starting units is orthogonal: units may be enabled without being started and started without being enabled. Enabling simply hooks the unit into various suggested places (for example, so that the unit is automatically started on boot or when a particular kind of hardware is plugged in). Starting actually spawns the daemon process (in case of service units), or binds the socket (in case of socket units), and so on.

To actually start the daemon now instead of at the next login:

combine this command with the --now switch, or invoke start with appropriate arguments later.

Upvotes: 1

Related Questions