0

I'm learning about s6 and I've come to a point where I want to use s6-log. I have the following Dockerfile

FROM alpine:3.10

RUN apk --no-cache --update add s6

WORKDIR /run/service

COPY \
  ./rootfs/run \
  ./rootfs/app /run/service/

CMD ["s6-supervise", "."]

with ./rootfs/app being just a simple sh script

#!/bin/sh

while true;
do
  sleep 1
  printf "Hello %s\n" "$(date)"
done

and run being

#!/bin/execlineb -P
fdmove -c 2 1
s6-log -b n20 s1000000 t /var/log/app/
/run/service/app

Why do I keep getting

s6-log: fatal: unable to open_append /run/service/app/lock: Not a directory

? Without the s6-log line it all works fine.

Patryk
  • 22,602
  • 44
  • 128
  • 244

1 Answers1

1

So it seems that I've been doing this incorrectly. Namely I should've used s6-svscan instead of s6-supervice. Using s6-svscan I can create a log/ subdirectory in my service's directory so that my app's stdout is redirected to logger's stdin as described on s6-svscan's website:

For every new subdirectory dir it finds, the scanner spawns a s6-supervise process on it. If dir/log exists, it spawns a s6-supervise process on both dir and dir/log, and maintains a never-closing pipe from the service's stdout to the logger's stdin.

I've written run script like so:

#!/bin/execlineb -P
s6-log -b n20 s512 T /var/log/app

and with that I've changed the CMD to

CMD ["s6-svscan", "/run/"]

where /run/service/ contains both run script for my service (without s6-log call) and log subdirectory with the run script above.

Patryk
  • 22,602
  • 44
  • 128
  • 244