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

Docker/8.5.2: Command Line Arguments not recognized? #1110

Closed
maddes-b opened this issue Jun 4, 2024 · 4 comments
Closed

Docker/8.5.2: Command Line Arguments not recognized? #1110

maddes-b opened this issue Jun 4, 2024 · 4 comments

Comments

@maddes-b
Copy link

maddes-b commented Jun 4, 2024

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.

@michaelherger
Copy link
Member

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...

@maddes-b
Copy link
Author

maddes-b commented Jun 5, 2024

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.

@maddes-b
Copy link
Author

maddes-b commented Jun 5, 2024

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

@maddes-b maddes-b changed the title 8.5.2: Command Line Arguments not recognized? Docker/8.5.2: Command Line Arguments not recognized? Jun 5, 2024
@maddes-b
Copy link
Author

maddes-b commented Jun 5, 2024

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.)

@maddes-b maddes-b closed this as completed Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants