System journal is flooded with filebrowser messages

Hi,

When my Zynthian v5.1 ORAM-2504.1 is running without a network, the journal is flooded with filebrowser restart and error messages. They are fired once every 2 seconds, so after a while there are hundreds of these messages making journalctl unusable.

May 27 14:45:15 zynthian systemd[1]: filebrowser.service: Scheduled restart job, restart counter is at 1.
May 27 14:45:15 zynthian systemd[1]: Stopped filebrowser.service - Zynthian File Browser.
May 27 14:45:15 zynthian systemd[1]: Started filebrowser.service - Zynthian File Browser.
May 27 14:45:15 zynthian filebrowser.sh[1087]: Error: flag needs an argument: 'a' in -a
May 27 14:45:15 zynthian filebrowser.sh[1087]: Usage:
May 27 14:45:15 zynthian filebrowser.sh[1087]:   filebrowser [flags]
May 27 14:45:15 zynthian filebrowser.sh[1087]:   filebrowser [command]
May 27 14:45:15 zynthian filebrowser.sh[1087]: Available Commands:
May 27 14:45:15 zynthian filebrowser.sh[1087]:   cmds        Command runner management utility
May 27 14:45:15 zynthian filebrowser.sh[1087]:   completion  Generate the autocompletion script for the specified shell
May 27 14:45:15 zynthian filebrowser.sh[1087]:   config      Configuration management utility
May 27 14:45:15 zynthian filebrowser.sh[1087]:   hash        Hashes a password
May 27 14:45:15 zynthian filebrowser.sh[1087]:   help        Help about any command
May 27 14:45:15 zynthian filebrowser.sh[1087]:   rules       Rules management utility
May 27 14:45:15 zynthian filebrowser.sh[1087]:   upgrade     Upgrades an old configuration
May 27 14:45:15 zynthian filebrowser.sh[1087]:   users       Users management utility
May 27 14:45:15 zynthian filebrowser.sh[1087]:   version     Print the version number
May 27 14:45:15 zynthian filebrowser.sh[1087]: Flags:
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -a, --address string                     address to listen on (default ">
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -b, --baseurl string                     base url
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --cache-dir string                   file cache directory (disabled >
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -t, --cert string                        tls certificate
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -c, --config string                      config file path
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -d, --database string                    database path (default "./fileb>
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --disable-exec                       disables Command Runner feature
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --disable-preview-resize             disable resize of image previews
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --disable-thumbnails                 disable image thumbnails
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --disable-type-detection-by-header   disables type detection by read>
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -h, --help                               help for filebrowser
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --img-processors int                 image processors count (default>
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -k, --key string                         tls key
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -l, --log string                         log output (default "stdout")
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --noauth                             use the noauth auther when usin>
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --password string                    hashed password for the first u>
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -p, --port string                        port to listen on (default "808>
May 27 14:45:15 zynthian filebrowser.sh[1087]:   -r, --root string                        root to prepend to relative pat>
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --socket string                      socket to listen to (cannot be >
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --socket-perm uint32                 unix socket file permissions (d>
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --token-expiration-time string       user session timeout (default ">
May 27 14:45:15 zynthian filebrowser.sh[1087]:       --username string                    username for the first user whe>
May 27 14:45:15 zynthian filebrowser.sh[1087]: Use "filebrowser [command] --help" for more information about a command.
May 27 14:45:15 zynthian filebrowser.sh[1087]: 2025/05/27 14:45:15 flag needs an argument: 'a' in -a
May 27 14:45:15 zynthian systemd[1]: filebrowser.service: Main process exited, code=exited, status=1/FAILURE
May 27 14:45:15 zynthian systemd[1]: filebrowser.service: Failed with result 'exit-code'.

I repaired this by adding some conditions to the systemd service file (/etc/systemd/system/filebrowser.service):

Original file:

[Unit]
Description=Zynthian File Browser

[Service]
Environment=HOME=/zynthian/zynthian-sw/filebrowser
Environment=ZYNTHIAN_DIR=/zynthian
Environment=ZYNTHIAN_SW_DIR=/zynthian/zynthian-sw
WorkingDirectory=/zynthian/zynthian-sw/filebrowser
ExecStart=/zynthian/zynthian-sys/sbin/filebrowser.sh
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

Adapted version:

  • Added dependency on network (without network the browser is useless)
  • limited the number of restarts to 2 (when it doesn’t work after two attempts, it probably won’t work at all)
  • restart after 3 seconds (gives it a little more time)
[Unit]
Description=Zynthian File Browser
Wants=network-online.target
After=network-online.target
StartLimitIntervalSec=15

[Service]
Environment=HOME=/zynthian/zynthian-sw/filebrowser
Environment=ZYNTHIAN_DIR=/zynthian
Environment=ZYNTHIAN_SW_DIR=/zynthian/zynthian-sw
WorkingDirectory=/zynthian/zynthian-sw/filebrowser
ExecStart=/zynthian/zynthian-sys/sbin/filebrowser.sh
Restart=always
RestartSec=3
StartLimitBurst=2

[Install]
WantedBy=multi-user.target

Starting with network enabled the browser runs at first attempt.

When you start without a network and plug a cable in later, you can always start the filebrowser using the terminal: systemctl start filebrowser. Or make a shell script fb that contains this command.

Hope this helps someone.

Kind regards,

Hans.

1 Like

Hi @HansR !!

Good try! But …

We need file browser service started automatically when network is available. Having to start the service by hand is not reliable and it’s going to cause much trouble.

Let me find a better solution, OK?

Regards,

OK! I have a better solution. I’ve modified this script:

/zynthian/zynthian-sys/sbin/filebrowser.sh

like this:

#!/bin/bash

#HOST_IP=$(hostname  -I | cut -f1 -d' ')
HOST_IP="0.0.0.0"
if [ "$HOST_IP" != "" ]; then
	cd $ZYNTHIAN_SW_DIR/filebrowser
	./filebrowser -a $HOST_IP
fi

This will start the filebrowser server not matter the network is on-line or not, using the catch-all IP address “0.0.0.0”.

So you can keep the system service file as it was before your mods and the system log will be free of garbage.

This change is on vangelis branch, but i will merge into oram staging ASAP.

Regards,

1 Like

Hi @jofemodo

That’s a quick fix, and it works great.

Thanks!

Hans.

1 Like