Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file.watch() does not work #4275

Open
brenc opened this issue Dec 18, 2024 · 6 comments
Open

file.watch() does not work #4275

brenc opened this issue Dec 18, 2024 · 6 comments
Labels

Comments

@brenc
Copy link

brenc commented Dec 18, 2024

Description

This code does not work:

file.watch(
  "/tmp/testfile",
  {print("testfile changed")},
)

I don't think this worked in 2.2 either (or earlier).

Steps to reproduce

Run the provided code then echo TEST >> /tmp/testfile.

Expected behavior

For the provided code to produce "testfile changed" when it's changed.

Liquidsoap version

2.3.0

Liquidsoap build config

* Liquidsoap version  : 2.3.0

 * Compilation options
   - Release build       : true
   - Git SHA             : (none)
   - OCaml version       : 4.14.2
   - OS type             : Unix
   - Libs versions       : alsa=0.3.0 angstrom=0.16.1 ao=0.2.4 asetmap=0.8.1 asn1-combinators=0.3.2 astring=0.8.5 base=v0.16.3 base.base_internalhash_types=v0.16.3 base.caml=v0.16.3 base.shadow_stdlib=v0.16.3 base64=3.5.1 bigarray=[distributed with Ocaml] bigarray-compat=1.1.0 bigstringaf=0.10.0 bjack=0.1.6 bos=0.2.1 bytes=[distributed with OCaml 4.02 or above] ca-certs=v1.0.0 camlp-streams camomile.lib=2.0 cohttp=5.3.1 cohttp-lwt=5.3.0 cohttp-lwt-unix=5.3.0 conduit=7.1.0 conduit-lwt=7.1.0 conduit-lwt-unix=7.1.0 cry=1.0.3 cstruct=6.2.0 ctypes=0.23.0 ctypes-foreign=0.23.0 ctypes.stubs=0.23.0 curl=0.9.2 digestif.c=1.2.0 domain-name=0.4.0 domain_shims dssi=0.1.5 dtools=0.4.5 dune-build-info=3.16.1 dune-private-libs.dune-section=3.16.1 dune-site=3.16.1 dune-site.private=3.16.1 duppy=0.9.4 eqaf=0.10 faad=0.5.2 fdkaac=0.3.3 ffmpeg-av=1.2.1 ffmpeg-avcodec=1.2.1 ffmpeg-avdevice=1.2.1 ffmpeg-avfilter=1.2.1 ffmpeg-avutil=1.2.1 ffmpeg-swresample=1.2.1 ffmpeg-swscale=1.2.1 fileutils=0.6.4 flac=0.5.1 flac.decoder=0.5.1 flac.ogg=0.5.1 fmt=0.9.0 fpath=0.7.3 frei0r=0.1.2 gd=1.1 gen=1.1 gmap=0.3.0 inotify=v2.6 integers ipaddr=5.6.0 ipaddr-sexp=5.6.0 ipaddr.unix=5.6.0 irc-client irc-client-unix kdf.hkdf=1.0.0 kdf.pbkdf=1.0.0 ladspa=0.2.2 lame=0.3.7 lastfm=0.3.4 lilv=0.2.0 liquidsoap-lang=2.3.0 liquidsoap-lang.console=2.3.0 liquidsoap_alsa=v2.3.0-2-g658a641 liquidsoap_ao=v2.3.0-2-g658a641 liquidsoap_bjack=v2.3.0-2-g658a641 liquidsoap_builtins=v2.3.0-2-g658a641 liquidsoap_core=v2.3.0-2-g658a641 liquidsoap_dssi=v2.3.0-2-g658a641 liquidsoap_faad=v2.3.0-2-g658a641 liquidsoap_fdkaac=v2.3.0-2-g658a641 liquidsoap_ffmpeg=v2.3.0-2-g658a641 liquidsoap_flac=v2.3.0-2-g658a641 liquidsoap_frei0r=v2.3.0-2-g658a641 liquidsoap_gd=v2.3.0-2-g658a641 liquidsoap_irc=v2.3.0-2-g658a641 liquidsoap_ladspa=v2.3.0-2-g658a641 liquidsoap_lame=v2.3.0-2-g658a641 liquidsoap_lastfm=v2.3.0-2-g658a641 liquidsoap_lilv=v2.3.0-2-g658a641 liquidsoap_lo=v2.3.0-2-g658a641 liquidsoap_mad=v2.3.0-2-g658a641 liquidsoap_ndi=v2.3.0-2-g658a641 liquidsoap_ogg=v2.3.0-2-g658a641 liquidsoap_ogg_flac=v2.3.0-2-g658a641 liquidsoap_optionals=v2.3.0-2-g658a641 liquidsoap_opus=v2.3.0-2-g658a641 liquidsoap_osc=v2.3.0-2-g658a641 liquidsoap_oss=v2.3.0-2-g658a641 liquidsoap_portaudio=v2.3.0-2-g658a641 liquidsoap_posix_time=v2.3.0-2-g658a641 liquidsoap_prometheus=v2.3.0-2-g658a641 liquidsoap_pulseaudio=v2.3.0-2-g658a641 liquidsoap_runtime=v2.3.0-2-g658a641 liquidsoap_samplerate=v2.3.0-2-g658a641 liquidsoap_sdl=v2.3.0-2-g658a641 liquidsoap_sdl_log_level=v2.3.0-2-g658a641 liquidsoap_shine=v2.3.0-2-g658a641 liquidsoap_soundtouch=v2.3.0-2-g658a641 liquidsoap_speex=v2.3.0-2-g658a641 liquidsoap_sqlite=v2.3.0-2-g658a641 liquidsoap_srt=v2.3.0-2-g658a641 liquidsoap_ssl=v2.3.0-2-g658a641 liquidsoap_stereotool=v2.3.0-2-g658a641 liquidsoap_theora=v2.3.0-2-g658a641 liquidsoap_tls=v2.3.0-2-g658a641 liquidsoap_vorbis=v2.3.0-2-g658a641 liquidsoap_xmlplaylist=v2.3.0-2-g658a641 liquidsoap_yaml=v2.3.0-2-g658a641 lo=0.2.0 logs=0.7.0 logs.fmt=0.7.0 logs.lwt=0.7.0 lwt lwt.unix macaddr=5.6.0 mad=0.5.3 magic-mime=1.3.1 mem_usage=0.1.1 memtrace=0.2.3 menhirLib=20240715 metadata=0.3.0 mirage-crypto=1.1.0 mirage-crypto-ec=1.1.0 mirage-crypto-pk=1.1.0 mirage-crypto-rng=1.1.0 mirage-crypto-rng.unix=1.1.0 mm=0.8.6 mm.audio=0.8.6 mm.base=0.8.6 mm.image=0.8.6 mm.midi=0.8.6 mm.video=0.8.6 ndi=v2.3.0-2-g658a641 ocplib-endian ocplib-endian.bigstring ogg=0.7.4 ogg.decoder=0.7.4 ohex opus=0.2.3 opus.decoder=0.2.3 osc osc-unix portaudio=0.2.3 posix-base=5a7f328 posix-socket=5a7f328 posix-socket.constants=5a7f328 posix-socket.stubs=5a7f328 posix-socket.types=5a7f328 posix-time2=5a7f328 posix-time2.constants=5a7f328 posix-time2.stubs=5a7f328 posix-time2.types=5a7f328 posix-types=5a7f328 posix-types.constants=5a7f328 ppx_compare.runtime-lib=v0.16.0 ppx_hash.runtime-lib=v0.16.0 ppx_sexp_conv.runtime-lib=v0.16.0 prometheus=1.2 prometheus-app=1.2 ptime=1.2.0 ptime.clock=1.2.0 ptime.clock.os=1.2.0 pulseaudio=0.1.6 re=1.12.0 result=1.5 rresult=0.7.0 samplerate=0.1.7 saturn_lockfree=0.4.1 sedlex=3.3 seq=[distributed with OCaml 4.07 or above] sexplib0=v0.16.0 shine=0.2.3 soundtouch=0.1.9 speex=0.4.2 speex.decoder=0.4.2 sqlite3=5.2.0 srt=0.3.1 srt.constants=0.3.1 srt.stubs=0.3.1 srt.stubs.locked=0.3.1 srt.types=0.3.1 ssl=0.7.0 stdlib-shims=0.3.0 stereotool=v2.3.0-2-g658a641 str=[distributed with Ocaml] stringext=1.6.0 theora=0.4.1 theora.decoder=0.4.1 threads=[distributed with Ocaml] threads.posix=[internal] tls=1.0.2 tsdl=v1.1.0 tsdl-image=0.5 tsdl-ttf=0.6 unix=[distributed with Ocaml] unix-errno=52c6ecb unix-errno.errno_bindings=52c6ecb unix-errno.errno_types=52c6ecb unix-errno.errno_types_detected=52c6ecb unix-errno.unix=52c6ecb uri=4.4.0 uri-sexp=4.4.0 uri.services=4.4.0 vorbis=0.8.1 vorbis.decoder=0.8.1 x509=1.0.5 xmlm=1.4.0 xmlplaylist=0.1.5 yaml=3.2.0 yaml.bindings=3.2.0 yaml.bindings.types=3.2.0 yaml.c=3.2.0 yaml.ffi=3.2.0 yaml.types=3.2.0 zarith=1.14
   - architecture        : amd64
   - host                : x86_64-pc-linux-gnu
   - target              : x86_64-pc-linux-gnu
   - system              : linux
   - ocamlopt_cflags     : -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC
   - native_c_compiler   : gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -D_FILE_OFFSET_BITS=64
   - native_c_libraries  : -lm

 * Configured paths
   - mode              : posix
   - standard library  : /usr/share/liquidsoap/libs
   - scripted binaries : /usr/share/liquidsoap/bin
   - rundir            : /var/run/liquidsoap
   - logdir            : /var/log/liquidsoap
   - user cache        : $HOME/.cache/liquidsoap (override with $LIQ_CACHE_USER_DIR)
   - system cache      : /var/cache/liquidsoap (override with $LIQ_CACHE_SYSTEM_DIR)
   - camomile files    : /usr/share/liquidsoap/camomile

 * Supported input formats
   - MP3               : yes
   - AAC               : yes
   - Ffmpeg            : yes
   - Flac (native)     : yes
   - Flac (ogg)        : yes
   - Opus              : yes
   - Speex             : yes
   - Theora            : yes
   - Vorbis            : yes
   - WAV/AIFF          : yes (native)

 * Supported output formats
   - FDK-AAC           : yes
   - FFmpeg            : yes
   - MP3               : yes
   - MP3 (fixed-point) : yes
   - Flac (native)     : yes
   - Flac (ogg)        : yes
   - Opus              : yes
   - Speex             : yes
   - Theora            : yes
   - Vorbis            : yes
   - WAV/AIFF          : yes (native)

 * Tags
   - AAC               : yes
   - FFmpeg            : yes
   - FLAC (native)     : yes
   - Flac (ogg)        : yes
   - Native decoder    : yes
   - Vorbis            : yes

 * Input / output
   - ALSA              : yes
   - AO                : yes
   - FFmpeg            : yes
   - JACK              : yes
   - NDI               : yes
   - OSS               : yes
   - Portaudio         : yes
   - Pulseaudio        : yes
   - SRT               : yes

 * Audio manipulation
   - FFmpeg            : yes
   - LADSPA            : yes
   - Lilv              : yes
   - Samplerate        : yes
   - SoundTouch        : yes
   - StereoTool        : yes

 * Video manipulation
   - camlimages        : no (requires camlimages)
   - FFmpeg            : yes
   - frei0r            : yes
   - ImageLib          : no (requires imagelib)
   - SDL               : yes

 * MIDI manipulation
   - DSSI              : yes

 * Visualization
   - GD                : yes
   - Graphics          : no (requires graphics)
   - SDL               : yes

 * Additional libraries
   - FFmpeg filters    : yes
   - FFmpeg devices    : yes
   - inotify           : yes
   - irc               : yes
   - jemalloc          : no (requires jemalloc)
   - lastfm            : yes
   - lo                : yes
   - memtrace          : yes
   - osc               : yes
   - ssl               : yes
   - sqlite3           : yes
   - tls               : yes
   - posix-time2       : yes
   - windows service   : no (requires winsvc)
   - YAML support      : yes
   - XML playlists     : yes

 * Monitoring
   - Prometheus        : yes

Installation method

From official container image

Additional Info

No response

@brenc brenc added the bug label Dec 18, 2024
@gAlleb
Copy link
Contributor

gAlleb commented Dec 18, 2024

Couldn't reproduce. Works fine with me.

Build-config
 % liquidsoap --build-config

 * Liquidsoap version  : rolling-release-v2.3.x-48-g5cb4ad6+dev

 * Compilation options
   - Release build       : false
   - Git SHA             : (none)
   - OCaml version       : 4.14.2
   - OS type             : Unix
   - Libs versions       : angstrom=0.16.1 ao=0.2.4 base=v0.16.3 base.base_internalhash_types=v0.16.3 base.caml=v0.16.3 base.shadow_stdlib=v0.16.3 bigarray=[distributed with Ocaml] bigstringaf=0.10.0 bytes=[distributed with OCaml 4.02 or above] camlp-streams camomile.lib=2.0 cry=1.0.3 curl=0.9.2 domain_shims dtools=0.4.5 dune-build-info=3.17.0 dune-private-libs.dune-section=3.17.0 dune-site=3.17.0 dune-site.private=3.17.0 duppy=0.9.4 ffmpeg-av=1.2.1 ffmpeg-avcodec=1.2.1 ffmpeg-avdevice=1.2.1 ffmpeg-avfilter=1.2.1 ffmpeg-avutil=1.2.1 ffmpeg-swresample=1.2.1 ffmpeg-swscale=1.2.1 fileutils=0.6.4 gen=1.1 lame=0.3.7 liquidsoap-lang=rolling-release-v2.3.x-48-g5cb4ad6 liquidsoap-lang.console=rolling-release-v2.3.x-48-g5cb4ad6 liquidsoap_ao=rolling-release-v2.3.x-48-g5cb4ad6-dirty liquidsoap_builtins=rolling-release-v2.3.x-48-g5cb4ad6-dirty liquidsoap_core=rolling-release-v2.3.x-48-g5cb4ad6-dirty liquidsoap_ffmpeg=rolling-release-v2.3.x-48-g5cb4ad6-dirty liquidsoap_lame=rolling-release-v2.3.x-48-g5cb4ad6-dirty liquidsoap_optionals=rolling-release-v2.3.x-48-g5cb4ad6-dirty liquidsoap_portaudio=rolling-release-v2.3.x-48-g5cb4ad6-dirty liquidsoap_runtime=rolling-release-v2.3.x-48-g5cb4ad6-dirty liquidsoap_xmlplaylist=rolling-release-v2.3.x-48-g5cb4ad6-dirty magic-mime=1.3.1 mem_usage=0.1.1 menhirLib=20240715 metadata=0.3.0 mm=0.8.6 mm.audio=0.8.6 mm.base=0.8.6 mm.image=0.8.6 mm.midi=0.8.6 mm.video=0.8.6 portaudio=0.2.3 ppx_compare.runtime-lib=v0.16.0 ppx_hash.runtime-lib=v0.16.0 ppx_sexp_conv.runtime-lib=v0.16.0 re=1.12.0 saturn_lockfree=0.4.1 sedlex=3.3 seq=[distributed with OCaml 4.07 or above] sexplib0=v0.16.0 stdlib-shims=0.3.0 str=[distributed with Ocaml] stringext=1.6.0 threads=[distributed with Ocaml] threads.posix=[internal] unix=[distributed with Ocaml] uri=4.4.0 xml-light=2.5 xmlm=1.4.0 xmlplaylist=0.1.5
   - architecture        : amd64
   - host                : x86_64-apple-darwin22.6.0
   - target              : x86_64-apple-darwin22.6.0
   - system              : macosx
   - ocamlopt_cflags     : -O2 -fno-strict-aliasing -fwrapv -pthread
   - native_c_compiler   : cc -O2 -fno-strict-aliasing -fwrapv -pthread -D_FILE_OFFSET_BITS=64
   - native_c_libraries  : -lm

 * Configured paths
   - mode              : default
   - standard library  : (set by dune-site)
   - scripted binaries : (set by dune-site)
   - rundir            : (set by dune-site)
   - logdir            : (set by dune-site)
   - user cache        : $HOME/.cache/liquidsoap (override with $LIQ_CACHE_USER_DIR)
   - system cache      : (set by dune-site) (override with $LIQ_CACHE_SYSTEM_DIR)
   - camomile files    : (set by dune-site)

 * Supported input formats
   - MP3               : no (requires mad)
   - AAC               : no (requires faad)
   - Ffmpeg            : yes
   - Flac (native)     : no (requires flac)
   - Flac (ogg)        : no (requires ogg)
   - Opus              : no (requires opus)
   - Speex             : no (requires speex)
   - Theora            : no (requires theora)
   - Vorbis            : no (requires vorbis)
   - WAV/AIFF          : yes (native)

 * Supported output formats
   - FDK-AAC           : no (requires fdkaac)
   - FFmpeg            : yes
   - MP3               : yes
   - MP3 (fixed-point) : no (requires shine)
   - Flac (native)     : no (requires flac)
   - Flac (ogg)        : no (requires ogg)
   - Opus              : no (requires opus)
   - Speex             : no (requires speex)
   - Theora            : no (requires theora)
   - Vorbis            : no (requires vorbis)
   - WAV/AIFF          : yes (native)

 * Tags
   - AAC               : no (requires faad)
   - FFmpeg            : yes
   - FLAC (native)     : no (requires flac)
   - Flac (ogg)        : no (requires ogg)
   - Native decoder    : yes
   - Vorbis            : no (requires vorbis)

 * Input / output
   - ALSA              : no (requires alsa)
   - AO                : yes
   - FFmpeg            : yes
   - JACK              : no (requires bjack)
   - NDI               : no (requires ctypes-foreign)
   - OSS               : no (requires oss)
   - Portaudio         : yes
   - Pulseaudio        : no (requires pulseaudio)
   - SRT               : no (requires srt)

 * Audio manipulation
   - FFmpeg            : yes
   - LADSPA            : no (requires ladspa)
   - Lilv              : no (requires lilv)
   - Samplerate        : no (requires samplerate)
   - SoundTouch        : no (requires soundtouch)
   - StereoTool        : no (requires ctypes-foreign)

 * Video manipulation
   - camlimages        : no (requires camlimages)
   - FFmpeg            : yes
   - frei0r            : no (requires frei0r)
   - ImageLib          : no (requires imagelib)
   - SDL               : no (requires tsdl-image & tsdl-ttf)

 * MIDI manipulation
   - DSSI              : no (requires dssi)

 * Visualization
   - GD                : no (requires gd)
   - Graphics          : no (requires graphics)
   - SDL               : no (requires tsdl-image & tsdl-ttf)

 * Additional libraries
   - FFmpeg filters    : yes
   - FFmpeg devices    : yes
   - inotify           : no (requires inotify)
   - irc               : no (requires irc-client-unix)
   - jemalloc          : no (requires jemalloc)
   - lo                : no (requires lo)
   - memtrace          : no (requires memtrace)
   - osc               : no (requires osc-unix)
   - ssl               : no (requires ssl)
   - sqlite3           : no (requires sqlite3)
   - tls               : no (requires tls-liquidsoap)
   - posix-time2       : no (requires posix)
   - windows service   : no (requires winsvc)
   - YAML support      : no (requires yaml)
   - XML playlists     : yes

 * Monitoring
   - Prometheus        : no (requires prometheus)

Update: on docker savonet/liquidsoap:v2.3.0 doesn't work indeed.

@brenc
Copy link
Author

brenc commented Dec 18, 2024

Minimally reproducible script:

process.run("touch /tmp/testfile")

file.watch(
  "/tmp/testfile",
  {print("file changed")},
)

while true do
  print("writing")
  process.run("echo #{time()} >> /tmp/testfile")
  thread.pause(1.0)
end

I see "writing" every 1s but no "file changed".

@gAlleb
Copy link
Contributor

gAlleb commented Dec 18, 2024

Well, it does work fine, just doesn't print the info with your method on savonet/liquidsoap:v2.3.0 linux build.

success = ref(false)
file.watch(
  "/tmp/testfile",
  {success := true},
)
thread.run(every=1.,fun() -> print("#{success()}"))
output.dummy(sine())

ref gets changed.

file.watch(
  "/tmp/testfile",
  {log("file has changed")},
)

log works too.

And print works too if we alter your function a little:

file.watch(
  "/tmp/testfile",
  fun() -> print("file has changed"),
)

Actually I have tried again with {print("testfile changed")}, and it seems to work too) Hm)

Everything seems to work on this build too:

This build
 * Liquidsoap version  : 2.3.0

 * Compilation options
   - Release build       : true
   - Git SHA             : (none)
   - OCaml version       : 4.14.2
   - OS type             : Unix
   - Libs versions       : alsa=0.3.0 angstrom=0.16.1 ao=0.2.4 asetmap=0.8.1 asn1-combinators=0.3.2 astring=0.8.5 base=v0.16.3 base.base_internalhash_types=v0.16.3 base.caml=v0.16.3 base.shadow_stdlib=v0.16.3 base64=3.5.1 bigarray=[distributed with Ocaml] bigarray-compat=1.1.0 bigstringaf=0.10.0 bjack=0.1.6 bos=0.2.1 bytes=[distributed with OCaml 4.02 or above] ca-certs=v1.0.0 camlp-streams camomile.lib=2.0 cohttp=5.3.1 cohttp-lwt=5.3.0 cohttp-lwt-unix=5.3.0 conduit=7.1.0 conduit-lwt=7.1.0 conduit-lwt-unix=7.1.0 cry=1.0.3 cstruct=6.2.0 ctypes=0.23.0 ctypes-foreign=0.23.0 ctypes.stubs=0.23.0 curl=0.9.2 digestif.c=1.2.0 domain-name=0.4.0 domain_shims dssi=0.1.5 dtools=0.4.5 dune-build-info=3.16.1 dune-private-libs.dune-section=3.16.1 dune-site=3.16.1 dune-site.private=3.16.1 duppy=0.9.4 eqaf=0.10 faad=0.5.2 fdkaac=0.3.3 ffmpeg-av=1.2.1 ffmpeg-avcodec=1.2.1 ffmpeg-avdevice=1.2.1 ffmpeg-avfilter=1.2.1 ffmpeg-avutil=1.2.1 ffmpeg-swresample=1.2.1 ffmpeg-swscale=1.2.1 fileutils=0.6.4 flac=0.5.1 flac.decoder=0.5.1 flac.ogg=0.5.1 fmt=0.9.0 fpath=0.7.3 frei0r=0.1.2 gd=1.1 gen=1.1 gmap=0.3.0 inotify=v2.6 integers ipaddr=5.6.0 ipaddr-sexp=5.6.0 ipaddr.unix=5.6.0 irc-client irc-client-unix kdf.hkdf=1.0.0 kdf.pbkdf=1.0.0 ladspa=0.2.2 lame=0.3.7 lastfm=0.3.4 lilv=0.2.0 liquidsoap-lang=2.3.0 liquidsoap-lang.console=2.3.0 liquidsoap_alsa=v2.3.0-2-g658a641 liquidsoap_ao=v2.3.0-2-g658a641 liquidsoap_bjack=v2.3.0-2-g658a641 liquidsoap_builtins=v2.3.0-2-g658a641 liquidsoap_core=v2.3.0-2-g658a641 liquidsoap_dssi=v2.3.0-2-g658a641 liquidsoap_faad=v2.3.0-2-g658a641 liquidsoap_fdkaac=v2.3.0-2-g658a641 liquidsoap_ffmpeg=v2.3.0-2-g658a641 liquidsoap_flac=v2.3.0-2-g658a641 liquidsoap_frei0r=v2.3.0-2-g658a641 liquidsoap_gd=v2.3.0-2-g658a641 liquidsoap_irc=v2.3.0-2-g658a641 liquidsoap_ladspa=v2.3.0-2-g658a641 liquidsoap_lame=v2.3.0-2-g658a641 liquidsoap_lastfm=v2.3.0-2-g658a641 liquidsoap_lilv=v2.3.0-2-g658a641 liquidsoap_lo=v2.3.0-2-g658a641 liquidsoap_mad=v2.3.0-2-g658a641 liquidsoap_ndi=v2.3.0-2-g658a641 liquidsoap_ogg=v2.3.0-2-g658a641 liquidsoap_ogg_flac=v2.3.0-2-g658a641 liquidsoap_optionals=v2.3.0-2-g658a641 liquidsoap_opus=v2.3.0-2-g658a641 liquidsoap_osc=v2.3.0-2-g658a641 liquidsoap_oss=v2.3.0-2-g658a641 liquidsoap_portaudio=v2.3.0-2-g658a641 liquidsoap_posix_time=v2.3.0-2-g658a641 liquidsoap_prometheus=v2.3.0-2-g658a641 liquidsoap_pulseaudio=v2.3.0-2-g658a641 liquidsoap_runtime=v2.3.0-2-g658a641 liquidsoap_samplerate=v2.3.0-2-g658a641 liquidsoap_sdl=v2.3.0-2-g658a641 liquidsoap_sdl_log_level=v2.3.0-2-g658a641 liquidsoap_shine=v2.3.0-2-g658a641 liquidsoap_soundtouch=v2.3.0-2-g658a641 liquidsoap_speex=v2.3.0-2-g658a641 liquidsoap_sqlite=v2.3.0-2-g658a641 liquidsoap_srt=v2.3.0-2-g658a641 liquidsoap_ssl=v2.3.0-2-g658a641 liquidsoap_stereotool=v2.3.0-2-g658a641 liquidsoap_theora=v2.3.0-2-g658a641 liquidsoap_tls=v2.3.0-2-g658a641 liquidsoap_vorbis=v2.3.0-2-g658a641 liquidsoap_xmlplaylist=v2.3.0-2-g658a641 liquidsoap_yaml=v2.3.0-2-g658a641 lo=0.2.0 logs=0.7.0 logs.fmt=0.7.0 logs.lwt=0.7.0 lwt lwt.unix macaddr=5.6.0 mad=0.5.3 magic-mime=1.3.1 mem_usage=0.1.1 memtrace=0.2.3 menhirLib=20240715 metadata=0.3.0 mirage-crypto=1.1.0 mirage-crypto-ec=1.1.0 mirage-crypto-pk=1.1.0 mirage-crypto-rng=1.1.0 mirage-crypto-rng.unix=1.1.0 mm=0.8.6 mm.audio=0.8.6 mm.base=0.8.6 mm.image=0.8.6 mm.midi=0.8.6 mm.video=0.8.6 ndi=v2.3.0-2-g658a641 ocplib-endian ocplib-endian.bigstring ogg=0.7.4 ogg.decoder=0.7.4 ohex opus=0.2.3 opus.decoder=0.2.3 osc osc-unix portaudio=0.2.3 posix-base=5a7f328 posix-socket=5a7f328 posix-socket.constants=5a7f328 posix-socket.stubs=5a7f328 posix-socket.types=5a7f328 posix-time2=5a7f328 posix-time2.constants=5a7f328 posix-time2.stubs=5a7f328 posix-time2.types=5a7f328 posix-types=5a7f328 posix-types.constants=5a7f328 ppx_compare.runtime-lib=v0.16.0 ppx_hash.runtime-lib=v0.16.0 ppx_sexp_conv.runtime-lib=v0.16.0 prometheus=1.2 prometheus-app=1.2 ptime=1.2.0 ptime.clock=1.2.0 ptime.clock.os=1.2.0 pulseaudio=0.1.6 re=1.12.0 result=1.5 rresult=0.7.0 samplerate=0.1.7 saturn_lockfree=0.4.1 sedlex=3.3 seq=[distributed with OCaml 4.07 or above] sexplib0=v0.16.0 shine=0.2.3 soundtouch=0.1.9 speex=0.4.2 speex.decoder=0.4.2 sqlite3=5.2.0 srt=0.3.1 srt.constants=0.3.1 srt.stubs=0.3.1 srt.stubs.locked=0.3.1 srt.types=0.3.1 ssl=0.7.0 stdlib-shims=0.3.0 stereotool=v2.3.0-2-g658a641 str=[distributed with Ocaml] stringext=1.6.0 theora=0.4.1 theora.decoder=0.4.1 threads=[distributed with Ocaml] threads.posix=[internal] tls=1.0.2 tsdl=v1.1.0 tsdl-image=0.5 tsdl-ttf=0.6 unix=[distributed with Ocaml] unix-errno=52c6ecb unix-errno.errno_bindings=52c6ecb unix-errno.errno_types=52c6ecb unix-errno.errno_types_detected=52c6ecb unix-errno.unix=52c6ecb uri=4.4.0 uri-sexp=4.4.0 uri.services=4.4.0 vorbis=0.8.1 vorbis.decoder=0.8.1 x509=1.0.5 xmlm=1.4.0 xmlplaylist=0.1.5 yaml=3.2.0 yaml.bindings=3.2.0 yaml.bindings.types=3.2.0 yaml.c=3.2.0 yaml.ffi=3.2.0 yaml.types=3.2.0 zarith=1.14
   - architecture        : amd64
   - host                : x86_64-pc-linux-gnu
   - target              : x86_64-pc-linux-gnu
   - system              : linux
   - ocamlopt_cflags     : -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC
   - native_c_compiler   : gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -D_FILE_OFFSET_BITS=64
   - native_c_libraries  : -lm

 * Configured paths
   - mode              : posix
   - standard library  : /usr/share/liquidsoap/libs
   - scripted binaries : /usr/share/liquidsoap/bin
   - rundir            : /var/run/liquidsoap
   - logdir            : /var/log/liquidsoap
   - user cache        : $HOME/.cache/liquidsoap (override with $LIQ_CACHE_USER_DIR)
   - system cache      : /var/cache/liquidsoap (override with $LIQ_CACHE_SYSTEM_DIR)
   - camomile files    : /usr/share/liquidsoap/camomile

 * Supported input formats
   - MP3               : yes
   - AAC               : yes
   - Ffmpeg            : yes
   - Flac (native)     : yes
   - Flac (ogg)        : yes
   - Opus              : yes
   - Speex             : yes
   - Theora            : yes
   - Vorbis            : yes
   - WAV/AIFF          : yes (native)

 * Supported output formats
   - FDK-AAC           : yes
   - FFmpeg            : yes
   - MP3               : yes
   - MP3 (fixed-point) : yes
   - Flac (native)     : yes
   - Flac (ogg)        : yes
   - Opus              : yes
   - Speex             : yes
   - Theora            : yes
   - Vorbis            : yes
   - WAV/AIFF          : yes (native)

 * Tags
   - AAC               : yes
   - FFmpeg            : yes
   - FLAC (native)     : yes
   - Flac (ogg)        : yes
   - Native decoder    : yes
   - Vorbis            : yes

 * Input / output
   - ALSA              : yes
   - AO                : yes
   - FFmpeg            : yes
   - JACK              : yes
   - NDI               : yes
   - OSS               : yes
   - Portaudio         : yes
   - Pulseaudio        : yes
   - SRT               : yes

 * Audio manipulation
   - FFmpeg            : yes
   - LADSPA            : yes
   - Lilv              : yes
   - Samplerate        : yes
   - SoundTouch        : yes
   - StereoTool        : yes

 * Video manipulation
   - camlimages        : no (requires camlimages)
   - FFmpeg            : yes
   - frei0r            : yes
   - ImageLib          : no (requires imagelib)
   - SDL               : yes

 * MIDI manipulation
   - DSSI              : yes

 * Visualization
   - GD                : yes
   - Graphics          : no (requires graphics)
   - SDL               : yes

 * Additional libraries
   - FFmpeg filters    : yes
   - FFmpeg devices    : yes
   - inotify           : yes
   - irc               : yes
   - jemalloc          : no (requires jemalloc)
   - lastfm            : yes
   - lo                : yes
   - memtrace          : yes
   - osc               : yes
   - ssl               : yes
   - sqlite3           : yes
   - tls               : yes
   - posix-time2       : yes
   - windows service   : no (requires winsvc)
   - YAML support      : yes
   - XML playlists     : yes

 * Monitoring
   - Prometheus        : yes

This indeed doesn't work.

process.run("touch /tmp/testfile")

file.watch(
  "/tmp/testfile",
  {print("file changed")},
)

while true do
  print("writing")
  process.run("echo #{time()} >> /tmp/testfile")
  thread.pause(1.0)
end

However this works.

process.run("touch /tmp/testfile")

file.watch(
  "/tmp/testfile",
  {print("file changed")},
)

def writeF()
  print("writing")
  process.run("echo #{time()} >>  /tmp/testfile")
end

thread.run(every=5.0, writeF)

output.dummy(sine())

@vitoyucepi
Copy link
Collaborator

Hi everyone,
The file.watch function may not be triggered when the file address has changed because it provides a high-level interface for inotify.
Here are some examples that come to mind

  1. vim doesn't trigger inotify on save;
  2. docker doesn't update file mounts.

@brenc
Copy link
Author

brenc commented Dec 18, 2024

Yeah I don't get what's going on. This more closely mimics what I was trying to do. It works for 30s or so after LS starts but then stops working:

process.run("touch /tmp/testfile")

file.watch(
  "/tmp/testfile",
  {print("file changed")},
)

output.dummy(sine())

Then in the console echo "TEST" >> /tmp/testfile in the container.

This also works for a bit, but then stops working (you'll see "writing" but no "file changed" after 20-30s):

process.run("touch /tmp/testfile")

file.watch(
  "/tmp/testfile",
  {print("file changed")},
)

def write()
  print("writing")
  process.run("echo #{time()} >> /tmp/testfile")
end

thread.run(every=1.0, write)

output.dummy(sine())

@vitoyucepi not using vim (that can be configured to trigger inotify, as I recall) and not using bind mounts. I've tried NFS, bind, and local container FS all same deal.

@vitoyucepi
Copy link
Collaborator

Got it 30 seconds after start, present in 2.3.0 but not in 2.2.5.

compose.yaml
services:
  ls22:
    image: savonet/liquidsoap:v2.2.5
    command: /tmp/test/main.liq
    volumes:
      - ./:/tmp/test/
  ls23:
    image: savonet/liquidsoap:v2.3.0
    command: /tmp/test/main.liq
    volumes:
      - ./:/tmp/test/
mail.liq
process.run("touch /tmp/testfile")

file.watch(
  "/tmp/testfile",
  {print("#{time.up()} file changed")},
)

def write()
  state = process.run("stat -c '%i' /tmp/testfile")
  print("#{time.up()} #{string.trim(state.stdout)} writing")
  process.run("echo #{time()} >> /tmp/testfile")
end

thread.run(every=1.0, write)

output.dummy(sine())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants