The officially official Devuan Forum!

You are not logged in.

#1 2023-11-29 07:11:08

chomwitt
Member
Registered: 2019-09-24
Posts: 130  

runit services : Trying to create an emacs service

I can start the emacs service and then start an emacs frame as a client with:

$ emacs --fg-daemon=chomwitt-emacsd 
$ emacsclient --socket-name=chomwitt-emacsd

$ ps -aux | grep emacs
chomwitt   494  0.0  0.0   6692  2088 pts/0    S+   09:05   0:00 grep emacs
chomwitt 31778  0.0  0.2 679544 139624 pts/4   Sl+  Nov28   0:01 emacs --fg-daemon=chomwitt-emacsd

Now i tried to create a service with:

$ less /etc/sv/emacs/run 
#!/usr/bin/env /lib/runit/invoke-run
export HOME=/home/chomwitt
exec 2>&1
cd $HOME
exec chpst -u chomwitt:chomwitt /usr/bin/emacs --fg-daemon=chomwitt-emacsd 

And then i start the service with:

$ sudo ln -s /etc/sv/emacs /etc/service/emacsd
$ ps -aux | grep emacs
root       622  0.0  0.0   2344  1040 ?        Ss   09:07   0:00 runsv emacsd
chomwitt   623  5.5  0.1 224348 110176 ?       S    09:07   0:00 /usr/bin/emacs --fg-daemon=chomwitt-emacsd
chomwitt   660  0.0  0.0   6692  2088 pts/0    S+   09:07   0:00 grep emacs

But now triying to start a client i get a 'cant find the service' error:

$ emacsclient  --socket-name=chomwitt-emacsd -c
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".
emacsclient: error accessing socket "chomwitt-emacsd"

My sources that i initially based my effort:
  Lorenzo Puliti 's   runit-services
  Emacs daemon as a runit service by  Hristos N. Triantafillou
(Hristos has blogged also Emacs daemon as a runit "user service" but
i decided to try first the option that it seems to me more common and simple and suit me since i dont share my computer)

Last edited by chomwitt (2023-11-29 09:05:56)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#2 2023-11-29 10:19:15

chomwitt
Member
Registered: 2019-09-24
Posts: 130  

Re: runit services : Trying to create an emacs service

I've managed to start emacslient .

$ lsof -c emacs
emacs   623 chomwitt    6u     unix 0x000000006612cb3d      0t0  1292858 /tmp/emacs1000/chomwitt-emacsd type=STREAM (LISTEN)
$ emacsclient -s /tmp/emacs1000/chomwitt-emacsd -c  .

when started from the command line it uses a different 'socket'.

$ lsof -c emacs
emacs   27340 chomwitt    6u     unix 0x00000000d0fa297b      0t0  1696185 /run/user/1000/emacs/chomwitt-emacsd type=STREAM (LISTEN)
emacs   27340 chomwitt    4u     unix 0x00000000331e1ac8      0t0  1518638 type=STREAM (CONNECTED)

My guess is that from command line emacs --fg-daemon=chomwitt-emacsd uses $XDG_RUNTIME_DIR
$ echo $XDG_RUNTIME_DIR
/run/user/1000

So i will try to make  $XDG_RUNTIME_DIR visible to my /etc/sv/emacs/run script

Last edited by chomwitt (2023-11-29 15:37:13)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#3 2023-11-29 16:38:00

chomwitt
Member
Registered: 2019-09-24
Posts: 130  

Re: runit services : Trying to create an emacs service

Ok. Here is the run script that allows emacsclient to connect without a full 'socket' name:

#!/usr/bin/env /lib/runit/invoke-run
export HOME=/home/chomwitt
export XDG_RUNTIME_DIR=/run/user/1000
exec 2>&1
cd $HOME
exec chpst -u chomwitt:chomwitt  emacs --fg-daemon=chomwitt-emacsd

Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#4 2023-12-05 17:38:30

chomwitt
Member
Registered: 2019-09-24
Posts: 130  

Re: runit services : Trying to create an emacs service

i had an issue with the service not opening a socket at reboot. I think maybe it has to do with the export XDG_RUNTIME_DIR=/run/user/1000.
Maybe is not set up until i log on ? In which case what should i do ? Try it as a user service ?


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

Board footer