all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How do you define a service?
@ 2020-10-17 15:07 divoplade
  2020-10-17 15:58 ` Wiktor Żelazny
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: divoplade @ 2020-10-17 15:07 UTC (permalink / raw)
  To: help-guix

Dear guix,

I have written a little maybe-non-trivial web server, and I would like
to make it available as a guix service.

I could not find documentation in the manual nor in the guix cookbook,
but it's entirely possible I was looking for the wrong thing. Do you
have any resources to share?

Best regards,

divoplade



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

* Re: How do you define a service?
  2020-10-17 15:07 How do you define a service? divoplade
@ 2020-10-17 15:58 ` Wiktor Żelazny
  2020-10-17 19:47   ` divoplade
  2020-10-17 21:42 ` divoplade
  2020-10-18  9:49 ` divoplade
  2 siblings, 1 reply; 12+ messages in thread
From: Wiktor Żelazny @ 2020-10-17 15:58 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

On Sat, Oct 17, 2020 at 05:07:20PM +0200, divoplade wrote:

> I would like to make it available as a guix service.

> Do you have any resources to share?

Hi divoplade,

You might want to take a look at [1].

WŻ

[1]: https://www.mndet.net/2016/05/04/guixsd-system-service.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 963 bytes --]

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

* Re: How do you define a service?
  2020-10-17 15:58 ` Wiktor Żelazny
@ 2020-10-17 19:47   ` divoplade
  2020-10-17 20:55     ` Julien Lepiller
  0 siblings, 1 reply; 12+ messages in thread
From: divoplade @ 2020-10-17 19:47 UTC (permalink / raw)
  To: Wiktor Żelazny, help-guix

Hello,

Le samedi 17 octobre 2020 à 17:58 +0200, Wiktor Żelazny a écrit :
> You might want to take a look at [1].
> 
> WŻ
> 
> [1]: https://www.mndet.net/2016/05/04/guixsd-system-service.html

This is exactly what I was looking for, although I needed to import
ice-9 optargs for the define* function. Results is here: 
https://code.divoplade.fr/pomdappi.git/tree/guix/divoplade/services/pomdappi.scm

I still have a problem: shepherd reports an exception when loading the
service:

Wrong type to apply: 17293

(or any number, it varies, maybe a PID).

Do you know what happens?

Best regards,

divoplade



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

* Re: How do you define a service?
  2020-10-17 19:47   ` divoplade
@ 2020-10-17 20:55     ` Julien Lepiller
  2020-10-17 21:08       ` divoplade
  0 siblings, 1 reply; 12+ messages in thread
From: Julien Lepiller @ 2020-10-17 20:55 UTC (permalink / raw)
  To: help-guix, divoplade, Wiktor Żelazny



Le 17 octobre 2020 15:47:50 GMT-04:00, divoplade <d@divoplade.fr> a écrit :
>Hello,
>
>Le samedi 17 octobre 2020 à 17:58 +0200, Wiktor Żelazny a écrit :
>> You might want to take a look at [1].
>> 
>> WŻ
>> 
>> [1]: https://www.mndet.net/2016/05/04/guixsd-system-service.html
>
>This is exactly what I was looking for, although I needed to import
>ice-9 optargs for the define* function. Results is here: 
>https://code.divoplade.fr/pomdappi.git/tree/guix/divoplade/services/pomdappi.scm
>
>I still have a problem: shepherd reports an exception when loading the
>service:
>
>Wrong type to apply: 17293
>
>(or any number, it varies, maybe a PID).

Don't you have one pair of parentheses too much around make-forkexec-constructor? I think it may try to evaluate the result as a function with no argument if you do that.

>
>Do you know what happens?
>
>Best regards,
>
>divoplade


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

* Re: How do you define a service?
  2020-10-17 20:55     ` Julien Lepiller
@ 2020-10-17 21:08       ` divoplade
  0 siblings, 0 replies; 12+ messages in thread
From: divoplade @ 2020-10-17 21:08 UTC (permalink / raw)
  To: Julien Lepiller, help-guix, Wiktor Żelazny

Hello,

Le samedi 17 octobre 2020 à 16:55 -0400, Julien Lepiller a écrit :
> Don't you have one pair of parentheses too much around make-forkexec-
> constructor? I think it may try to evaluate the result as a function
> with no argument if you do that.

Indeed. Thank you!

divoplade



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

* Re: How do you define a service?
  2020-10-17 15:07 How do you define a service? divoplade
  2020-10-17 15:58 ` Wiktor Żelazny
@ 2020-10-17 21:42 ` divoplade
  2020-10-17 22:18   ` Julien Lepiller
  2020-10-18  9:49 ` divoplade
  2 siblings, 1 reply; 12+ messages in thread
From: divoplade @ 2020-10-17 21:42 UTC (permalink / raw)
  To: help-guix

Thank you for your answers. I now have a follow-up question. Where is
the log? It seems that my binary fails immediately and gets disabled,
but I would like to see the stack trace of the exception. Is it saved
somewhere, or do I have to manage log files within the program?

Best regards,

divoplade



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

* Re: How do you define a service?
  2020-10-17 21:42 ` divoplade
@ 2020-10-17 22:18   ` Julien Lepiller
  0 siblings, 0 replies; 12+ messages in thread
From: Julien Lepiller @ 2020-10-17 22:18 UTC (permalink / raw)
  To: help-guix, divoplade

You'll need to talk to syslogd somehow.

Le 17 octobre 2020 17:42:16 GMT-04:00, divoplade <d@divoplade.fr> a écrit :
>Thank you for your answers. I now have a follow-up question. Where is
>the log? It seems that my binary fails immediately and gets disabled,
>but I would like to see the stack trace of the exception. Is it saved
>somewhere, or do I have to manage log files within the program?
>
>Best regards,
>
>divoplade

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

* Re: How do you define a service?
  2020-10-17 15:07 How do you define a service? divoplade
  2020-10-17 15:58 ` Wiktor Żelazny
  2020-10-17 21:42 ` divoplade
@ 2020-10-18  9:49 ` divoplade
  2020-10-18 12:12   ` Julien Lepiller
  2 siblings, 1 reply; 12+ messages in thread
From: divoplade @ 2020-10-18  9:49 UTC (permalink / raw)
  To: help-guix

Hello,

It seems that the modules I import from my program are not available at
run-time when running it as a service. More precisely, the modules I
have defined in my packages cannot be loaded from the program.

So I assume that the guile load and compile paths are not set. My only
debugging tool is to put a sleep() in the code and check that the
service runs for a time or immediately fails. This is very
inconvenient, but since I cannot log anything I have no other choice.

How do I make sure that the load path and compile path are set when my
program is run as a service?

Best regards,

divoplade





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

* Re: How do you define a service?
  2020-10-18  9:49 ` divoplade
@ 2020-10-18 12:12   ` Julien Lepiller
  2020-10-18 14:53     ` divoplade
  0 siblings, 1 reply; 12+ messages in thread
From: Julien Lepiller @ 2020-10-18 12:12 UTC (permalink / raw)
  To: help-guix, divoplade

Mayée you could wrap it with its dependencies? There are some examples of wrap-program usage, with haunt for instance.

Le 18 octobre 2020 05:49:28 GMT-04:00, divoplade <d@divoplade.fr> a écrit :
>Hello,
>
>It seems that the modules I import from my program are not available at
>run-time when running it as a service. More precisely, the modules I
>have defined in my packages cannot be loaded from the program.
>
>So I assume that the guile load and compile paths are not set. My only
>debugging tool is to put a sleep() in the code and check that the
>service runs for a time or immediately fails. This is very
>inconvenient, but since I cannot log anything I have no other choice.
>
>How do I make sure that the load path and compile path are set when my
>program is run as a service?
>
>Best regards,
>
>divoplade

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

* Re: How do you define a service?
  2020-10-18 12:12   ` Julien Lepiller
@ 2020-10-18 14:53     ` divoplade
  2020-10-18 15:43       ` divoplade
  2020-10-18 16:42       ` Efraim Flashner
  0 siblings, 2 replies; 12+ messages in thread
From: divoplade @ 2020-10-18 14:53 UTC (permalink / raw)
  To: Julien Lepiller, help-guix

Thank you for your responses. I reduced down the problem further.

The following program, as run in a service, creates an *empty* file
"/tmp/wtf", and runs for a minute:

(format (open-output-file "/tmp/wtf") "WTF???\n")

(sleep 60)

The following program, as run in the same condition, create an *empty*
file and fails immediately:

(with-output-to-file "/tmp/wtf"
  (display "WTF???\n"))

(sleep 60)

So I think the question is rather, whether Guile can actually work in a
shepherd forkexec environment: I guess the standard ports are closed,
so maybe guile panics when it is time to flush the data, even if the
ports are redirected.

Do you have an example of a service written in guile that works in this
context?

Best regards,

divoplade



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

* Re: How do you define a service?
  2020-10-18 14:53     ` divoplade
@ 2020-10-18 15:43       ` divoplade
  2020-10-18 16:42       ` Efraim Flashner
  1 sibling, 0 replies; 12+ messages in thread
From: divoplade @ 2020-10-18 15:43 UTC (permalink / raw)
  To: Julien Lepiller, help-guix

Sorry, answering my own questions here...

Le dimanche 18 octobre 2020 à 16:53 +0200, divoplade a écrit :
> Thank you for your responses. I reduced down the problem further.
> 
> The following program, as run in a service, creates an *empty* file
> "/tmp/wtf", and runs for a minute:
> 
> (format (open-output-file "/tmp/wtf") "WTF???\n")
> 
> (sleep 60)
> 
> The following program, as run in the same condition, create an
> *empty*
> file and fails immediately:
> 
> (with-output-to-file "/tmp/wtf"
>   (display "WTF???\n"))
> 
> (sleep 60)
> 
> So I think the question is rather, whether Guile can actually work in
> a
> shepherd forkexec environment: I guess the standard ports are closed,
> so maybe guile panics when it is time to flush the data, even if the
> ports are redirected.

If the script is a shell script doing I/O with redirection, it works,
so it's definitely a guile problem.

> Do you have an example of a service written in guile that works in
> this
> context?

Looking at cuirass, it executes a shell script that runs guile. That's
what I will be doing I think.



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

* Re: How do you define a service?
  2020-10-18 14:53     ` divoplade
  2020-10-18 15:43       ` divoplade
@ 2020-10-18 16:42       ` Efraim Flashner
  1 sibling, 0 replies; 12+ messages in thread
From: Efraim Flashner @ 2020-10-18 16:42 UTC (permalink / raw)
  To: divoplade; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]

On Sun, Oct 18, 2020 at 04:53:17PM +0200, divoplade wrote:
> Thank you for your responses. I reduced down the problem further.
> 
> The following program, as run in a service, creates an *empty* file
> "/tmp/wtf", and runs for a minute:
> 
> (format (open-output-file "/tmp/wtf") "WTF???\n")
> 
> (sleep 60)
> 
> The following program, as run in the same condition, create an *empty*
> file and fails immediately:
> 
> (with-output-to-file "/tmp/wtf"
>   (display "WTF???\n"))
> 
> (sleep 60)
> 
> So I think the question is rather, whether Guile can actually work in a
> shepherd forkexec environment: I guess the standard ports are closed,
> so maybe guile panics when it is time to flush the data, even if the
> ports are redirected.

forkexec does close the standard ports. Unfortunately I don't see that
mentioned in the manual¹. I know it's mentioned somewhere in the code
but I can't find it anywhere right now.

> Do you have an example of a service written in guile that works in this
> context?
> 
> Best regards,
> 
> divoplade

¹ https://www.gnu.org/software/shepherd/manual/html_node/Service-De_002d-and-Constructors.html#Service-De_002d-and-Constructors

-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2020-10-18 16:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-17 15:07 How do you define a service? divoplade
2020-10-17 15:58 ` Wiktor Żelazny
2020-10-17 19:47   ` divoplade
2020-10-17 20:55     ` Julien Lepiller
2020-10-17 21:08       ` divoplade
2020-10-17 21:42 ` divoplade
2020-10-17 22:18   ` Julien Lepiller
2020-10-18  9:49 ` divoplade
2020-10-18 12:12   ` Julien Lepiller
2020-10-18 14:53     ` divoplade
2020-10-18 15:43       ` divoplade
2020-10-18 16:42       ` Efraim Flashner

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.