unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* trying to write my own herd service
@ 2022-11-04 23:21 Adam Kandur
  2022-11-05  9:02 ` Liliana Marie Prikler
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Kandur @ 2022-11-04 23:21 UTC (permalink / raw)
  To: guix-devel

Hi guix!
I tried to write my own herd service, that's what i did
```
(define (my-daemon-shepherd-service _)
  (list (shepherd-service
         (documentation "")
         (provision '(go-github-com-KefirTheAutomator-daemon))
         (requirement '(networking))
         (start #~(make-forkexec-constructor
                   (list
                    (string-append
#$go-github-com-KefirTheAutomator-daemon "/bin/daemon")
                    " -pidFile=/var/run/my-daemon.pid"
                    " -logFile=/var/log/my-daemon.log")))
         (stop #~(make-kill-destructor)))))

(define my-daemon-service-type
  (service-type (name 'my-daemon)
                (extensions
                 (list (service-extension shepherd-root-service-type
                                          my-daemon-shepherd-service)))
                (default-value #f)
                (description "")))
```
(go-github-com-KefirTheAutomator-daemon is my dummy daemon that just
creates a process and writes to it's log file).

This was pulled from my channel, but when I am trying to start the
services, it turns of and disables
```
user@workstation ~$ sudo herd status go-github-com-KefirTheAutomator-daemon
Status of go-github-com-KefirTheAutomator-daemon:
  It is stopped.
  It is disabled.
  Provides (go-github-com-KefirTheAutomator-daemon).
  Requires (networking).
  Conflicts with ().
  Will be respawned.
  Last respawned on Sat Nov 05 02:14:33+0300 2022.

```

Can anyone help me to find out what is wrong, I didn't find any
recommendations on writing herd services?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: trying to write my own herd service
  2022-11-04 23:21 trying to write my own herd service Adam Kandur
@ 2022-11-05  9:02 ` Liliana Marie Prikler
  2022-11-05 13:26   ` EuAndreh
  0 siblings, 1 reply; 3+ messages in thread
From: Liliana Marie Prikler @ 2022-11-05  9:02 UTC (permalink / raw)
  To: Adam Kandur, guix-devel

Am Samstag, dem 05.11.2022 um 02:21 +0300 schrieb Adam Kandur:
> Hi guix!
> I tried to write my own herd service, that's what i did
> ```
> (define (my-daemon-shepherd-service _)
>   (list (shepherd-service
>          (documentation "")
>          (provision '(go-github-com-KefirTheAutomator-daemon))
>          (requirement '(networking))
>          (start #~(make-forkexec-constructor
>                    (list
>                     (string-append
> #$go-github-com-KefirTheAutomator-daemon "/bin/daemon")
>                     " -pidFile=/var/run/my-daemon.pid"
>                     " -logFile=/var/log/my-daemon.log")))
>          (stop #~(make-kill-destructor)))))
> 
> (define my-daemon-service-type
>   (service-type (name 'my-daemon)
>                 (extensions
>                  (list (service-extension shepherd-root-service-type
>                                           my-daemon-shepherd-
> service)))
>                 (default-value #f)
>                 (description "")))
> ```
First things first, writing your own shepherd service from Guix adds a
layer of difficulty: Not only do you need to understand shepherd, you
also need to understand how Guix glues things together.  I would
recommend starting with a simple hand-written service, because that
makes it easier to invoke shepherd as a user and inspect its output.

> (go-github-com-KefirTheAutomator-daemon is my dummy daemon that just
> creates a process and writes to it's log file).
> 
> This was pulled from my channel, but when I am trying to start the
> services, it turns of and disables
> ```
> user@workstation ~$ sudo herd status go-github-com-KefirTheAutomator-
> daemon
> Status of go-github-com-KefirTheAutomator-daemon:
>   It is stopped.
>   It is disabled.
>   Provides (go-github-com-KefirTheAutomator-daemon).
>   Requires (networking).
>   Conflicts with ().
>   Will be respawned.
>   Last respawned on Sat Nov 05 02:14:33+0300 2022.
> 
> ```
> 
> Can anyone help me to find out what is wrong, I didn't find any
> recommendations on writing herd services?
Your process probably dies too often, thus causing shepherd to disable
it.  If it is intended to be a one-shot service, mark it as such.  If
not, check there are unfulfilled requirements.

Cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: trying to write my own herd service
  2022-11-05  9:02 ` Liliana Marie Prikler
@ 2022-11-05 13:26   ` EuAndreh
  0 siblings, 0 replies; 3+ messages in thread
From: EuAndreh @ 2022-11-05 13:26 UTC (permalink / raw)
  To: Adam Kandur, Liliana Marie Prikler, guix-devel

> >          (start #~(make-forkexec-constructor
> >                    (list
> >                     (string-append
> > #$go-github-com-KefirTheAutomator-daemon "/bin/daemon")
> >                     " -pidFile=/var/run/my-daemon.pid"
> >                     " -logFile=/var/log/my-daemon.log")))

[...]

> Your process probably dies too often, thus causing shepherd to disable
> it.

I'd guess that it is dying too often because it is failing to be launched.  The
extra spaces before the "-pidFile" and "-logFile" arguments aren't ignored, like
when in a shell, but are included explicitly.  A contrived equivalent example
is:

    $ ls -l
    total 36
    drwxr-xr-x  6 andreh users 4096 Nov  4 19:42 Desktop
    drwxr-xr-x  7 andreh users 4096 Oct 31 21:07 Documents
    ...
    $ ls '-l'
    total 36
    drwxr-xr-x  6 andreh users 4096 Nov  4 19:42 Desktop
    drwxr-xr-x  7 andreh users 4096 Oct 31 21:07 Documents
    ...
    $ ls ' -l'
    ls: cannot access ' -l': No such file or directory

I believe that a similar thing is happening to the options to your program, and
it is failing to execute because of that.  You could confirm it by looking that
the logs.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-05 13:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 23:21 trying to write my own herd service Adam Kandur
2022-11-05  9:02 ` Liliana Marie Prikler
2022-11-05 13:26   ` EuAndreh

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).