LMS-Community/slimserver

Docker/8.5.2: Command Line Arguments not recognized?

maddes-b opened this issue · 4 comments

With 8.5.2 docker image linux/amd64 (sha256:7434f3a6c9cbe2a69b5653d671965c24ed527bbab2301a3e0f8b7d32f5650fbe) it seems that command line arguments are ignored.
Tested with --norestart and --advertiseaddr.

Log says:

Starting Logitech Media Server on port 9000...
Using additional arguments: "--advertiseaddr 192.168.1.77 --nomysqueezebox --norestart"

No errors in any log.

But when logging values in Perl, then these are empty, although variables are accessed as done in other places.
(tested why main::canRestartServer() in slimserver.pl didn't deny restarts although --norestart was specified)

sub canRestartServer {
	my $result;
	$result = $::norestart;
	logWarning("norestart is $result");
	$result = $main::advertiseaddr;
	logWarning("advertiseaddr is $result");
	$result = $main::httpaddr;
	logWarning("httpaddr is $result");
	$result = Slim::Utils::Network::hostAddr();
	logWarning("hostAddr() is $result");
	...

Result:

[24-06-04 22:56:42.6352] main::canRestartServer (1129) Warning: norestart is 
[24-06-04 22:56:42.6354] main::canRestartServer (1131) Warning: advertiseaddr is 
[24-06-04 22:56:42.6355] main::canRestartServer (1133) Warning: httpaddr is 
[24-06-04 22:56:42.6356] main::canRestartServer (1135) Warning: hostAddr() is 172.19.0.2

Removed outdated --nomysqueezebox , tested again, but got same result.

Did I find a bug, or do I get something wrong?

Kind regards
Maddes

[Update/Solution]
EXTRA_ARGS in Docker configuration had enclosing quotes, which lead to the wrong parametes.
Note for myself (and others): do not quote EXTRA_ARGS in your docker config (compose.yaml, etc.)

P.S.:
While reading Perl 5.31 docs I recognized that our only creates aliases to existing variables, which I couldn't find in the source. And GetOptions() seems to need existing variables. Do not know if this could be the cause.
Not an Perl expert.

Hmm... I'm pretty sure advertiseaddr does work, as this is something that recently has been discussed in the forums: under certain circumstances you have to use that configuration to make certain features work. I'm a bit confused there...

Could also be changes in the Perl version, the docker image uses Debian 11 "bullseye" with Perl 5.32.1
On Sunday I will test the Perl argument handling separately and with the logging in the relared sub routine.

This is working on a clean Debian 11 VM:

#!/usr/bin/perl

require 5.010;
use strict;
use Getopt::Long;

package main;

my $user = "otto";
my $group = "jungs";
our $norestart;

sub initOptions {
	my $gotOptions = GetOptions(
		'user=s'        => \$user,
		'group=s'       => \$group,
		'norestart'     => \$norestart,
    );

    print("gotOptions [$gotOptions]\n");
}

sub main
{
    print("main starts\n");
    print STDERR (join("|",@ARGV),"\n");
	# command line options
	initOptions();
    print("user [$user]\n");
    print("group [$group]\n");
    print("norestart [$::norestart]\n");
    print STDERR (join("|",@ARGV),"\n");
}

main();

[Update 1] Also working in the Docker image. I assume the argument passing is an issue.

[Update 2] It's the passing of the args, I assume it's docker environment related.
Log ARGV splitted: --logdir|/config/logs|--cachedir|/config/cache|--httpport|9000|"--advertiseaddr|192.168.1.77|--norestart" (see the quotes from EXTRA_ARGS

Reason:
EXTRA_ARGS in Docker configuration had enclosing quotes, which lead to the wrong parametes.
Note for myself (and others): do not quote EXTRA_ARGS in your docker config (compose.yaml, etc.)