unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Yulran <yulran@posteo.net>
To: post@bonni.codes
Cc: help-guix@gnu.org
Subject: Re: trouble defining a shepherd service
Date: Mon, 02 Dec 2024 12:01:25 +0000	[thread overview]
Message-ID: <87jzci9tuy.fsf@posteo.net> (raw)
In-Reply-To: <8f98f94a896a188a078c09f0ef5c7c15@libre.brussels> (indieterminacy@libre.brussels's message of "Mon, 21 Oct 2024 09:52:15 +0200")

Hi,

I hope you found the solution in the meantime, but in case it helps, there's also an issue in your service-extension that will indeed cause 'Wrong type to apply' or 'Wrong type argument' errors when you try to build your system.

The second argument of service-extension should be a function that takes one argument (the configuration passed to openslides-service-type) and returns a valid configuration for shepherd-root-service-type, which I assume is a list of shepherd services (I only tried with home-shepherd-service-type).

Since you don't need a configuration, you can use 'const' to transform the constant list of services into a function. So something like this should work:

--8<---------------cut here---------------start------------->8---
(define-public openslides-service-type
  (service-type
   (name 'openslides)
   (description "The openslides-service-type")
   (extensions
    (list (service-extension shepherd-root-service-type
                             (const (list openslides-shepherd-service)))))
   (default-value '())))
--8<---------------cut here---------------end--------------->8---

On Mon, Oct 21 2024, indieterminacy wrote:

> Hey,
>
> A passing guess is that this line is incorrect:
>
>> #:directory „/var/openslides"
>
> Try redefining it to this incase:
>
> #:directory "/var/openslides"
>
> HTH
>
> On 2024-10-20 23:56, post@bonni.codes wrote:
>> Hello,
>> I am trying to define a shepherd service to add to my system
>> configuration. Reading the docs this is what I came up with:
>> (define openslides-shepherd-service
>>   (shepherd-service
>>    (documentation "Runs the openslides docker-compose.")
>>    (provision '(openslides))
>>    (requirement '(dockerd))
>>    (start #~(make-forkexec-constructor
>> 	     (list
>> 	      #$(file-append docker-compose "/bin/docker-compose")
>> 	      "up")
>> 	     #:directory „/var/openslides"
>> 	     #:log-file "/var/log/openslides.log"
>> 	     #:pid-file "/var/run/openslides.pid"
>> 	     #:user "openslides")
>> 	  )
>>    (stop #~(make-kill-destructor))))
>> (define openslides-service-type
>>   (service-type
>>    (name 'openslides)
>>    (description "The openslides-service-type")
>>    (extensions
>>     (list (service-extension shepherd-root-service-type
>> openslides-shepherd-service)))
>>   (default-value '())
>>   ))
>> The service only needs to run the docker-compose program in the
>> directory /var/openslides . There is no need for configuration.
>> If I build my operating system I get the following error:
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> Wrong type to apply: #<<shepherd-service> documentation: "Runs the
>> openslides docker-compose." provision: (openslides) requirement:
>> (dockerd) one-shot?: #f respawn?: #t respawn-limit: #f
>> respawn-delay: #f free-form: #f start: #<gexp
>> (make-forkexec-constructor (list #<gexp-input #<file-append
>> #<package docker-compose@1.29.2 gnu/packages/docker.scm:109
>> 7ff9068e96e0> "/bin/docker-compose">:out> "up") #:directory
>> "/var/openslides" #:log-file "/var/log/openslides.log" #:pid-file
>> "/var/run/openslides.pid" #:user "openslides")
>> /home/chris/helios-system/config.scm:38:10 7ff8fe625c00> stop:
>> #<gexp (make-kill-destructor)
>> /home/chris/helios-system/config.scm:47:9 7ff8fe625bd0> actions: ()
>> auto-start?: #t modules: ((shepherd service) ((guix build utils)
>> #:hide (delete)) (guix build syscalls))>
>> indicating that there ist something wrong with the value for the
>> start and stop fields.
>> Where am I going wrong?
>> Kind regards
>> bonni
>> -----BEGIN PGP PUBLIC KEY BLOCK-----
>> mDMEZCntaxYJKwYBBAHaRw8BAQdANbpRRBxZVlIewesVvBOh2tlJCuK22g9lL5ZP
>> 9xqJDtS0GGJvbm5pIDxwb3N0QGJvbm5pLmNvZGVzPoiWBBMWCAA+FiEE+lyu2HL6
>> Nk0naPZMGyPeqOa1B/sFAmQp7WsCGwMFCQWjmoAFCwkIBwIGFQoJCAsCBBYCAwEC
>> HgECF4AACgkQGyPeqOa1B/snGAEAzddi9IcK/2EkrqPy2xmmwzLTAexKqZQqa+EE
>> LdtcnNwBANV2xOXW6hASEz0SMz4FEbroFs2kv7by6Wcyy+Fxl0sHuDgEZCntaxIK
>> KwYBBAGXVQEFAQEHQMrBS1fZCE1tuYac2MjA9nZit9leM8zlnyiaY6CdO/cRAwEI
>> B4h+BBgWCAAmFiEE+lyu2HL6Nk0naPZMGyPeqOa1B/sFAmQp7WsCGwwFCQWjmoAA
>> CgkQGyPeqOa1B/v95wD+N/6tRrCX9nqumpXgD3aZ8gcyA1uFSYP02HLyIUIwMY4A
>> /2YC4i2z+G3nzMGBrfID2yXVJg4S4Bby/xOkDxKgYrYD
>> =EEtE
>> -----END PGP PUBLIC KEY BLOCK-----


      reply	other threads:[~2024-12-03  0:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-20 21:56 trouble defining a shepherd service post
2024-10-21  7:52 ` indieterminacy
2024-12-02 12:01   ` Yulran [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87jzci9tuy.fsf@posteo.net \
    --to=yulran@posteo.net \
    --cc=help-guix@gnu.org \
    --cc=post@bonni.codes \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).