Bug 17780 - Squeezebox server gets started twice (Logitech Media Server died. Restarting)
: Squeezebox server gets started twice (Logitech Media Server died. Restarting)
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Misc
: 7.7.0
: PC Ubuntu Linux
: P2 major with 1 vote (vote)
: ---
Assigned To: Unassigned bug - please assign me!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-22 02:15 UTC by member
Modified: 2011-12-02 15:55 UTC (History)
2 users (show)

See Also:
Category: Bug


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description member 2011-11-22 02:15:46 UTC
I am running 7.7.0 - r33614 on Ubuntu Server 10.04LTS
Every other week I find that squeezebox server gets started twice.
From the server log shown below it seems to me that the server gets restarted when the system thinks it has died.
Obviously though the server is not really dead because the log says that another server is still running.
The result is a system with a heavy load and a squeezebox server which does not work as intended.
When I look at the process list, I find 2 squeezebox server process trees running.
One process tree has the correct PID as listed in /var/run/squeezeboxserver.pid.
If I run 'service squeezeboxser stop' this process tree gets stopped.
The other tree can only be stopped by issuing a 'kill -9' to the PIDs.

This is how the process tree looks at normal operation:
# cat /var/run/squeezeboxserver.pid
3502

# ps -ef | grep squeeze
109       3502     1  0 08:45 ?        00:00:00 /bin/bash /usr/sbin/squeezeboxserver_safe /usr/sbin/squeezeboxserver --prefsdir /var/lib/squeezeboxserver/prefs --logdir /var/log/squeezeboxserver/ --cachedir /var/lib/squeezeboxserver/cache --charset=utf8
109       3504  3502  1 08:45 ?        00:01:46 /usr/bin/perl /usr/sbin/squeezeboxserver --prefsdir /var/lib/squeezeboxserver/prefs --logdir /var/log/squeezeboxserver/ --cachedir /var/lib/squeezeboxserver/cache --charset=utf8 --norestart


# head  /var/log/squeezeboxserver/server.log
2011-11-22 07:53:42 Logitech Media Server died. Restarting.
[11-11-22 07:53:46.0726] main::init (354) Starting Logitech Media Server (v7.7.0, r33614, Tue Oct 18 11:07:25 PDT 2011) perl 5.010001
[11-11-22 07:53:46.6033] Slim::Networking::UDP::init (39) FATAL: There is already another copy of the Logitech Media Server running on this machine. (Address already in use)
[11-11-22 07:53:46.6046] Log::Log4perl::Logger::and_die (868) Warning: FATAL: There is already another copy of the Logitech Media Server running on this machine. (Address already in use) at /usr/share/squeezeboxserver/lib/Log/Log4perl/Logger.pm line 900
2011-11-22 07:53:47 Logitech Media Server died. Restarting.
[11-11-22 07:53:51.0638] main::init (354) Starting Logitech Media Server (v7.7.0, r33614, Tue Oct 18 11:07:25 PDT 2011) perl 5.010001
[11-11-22 07:53:51.5842] Slim::Networking::UDP::init (39) FATAL: There is already another copy of the Logitech Media Server running on this machine. (Address already in use)
[11-11-22 07:53:51.5856] Log::Log4perl::Logger::and_die (868) Warning: FATAL: There is already another copy of the Logitech Media Server running on this machine. (Address already in use) at /usr/share/squeezeboxserver/lib/Log/Log4perl/Logger.pm line 900
2011-11-22 07:53:52 Logitech Media Server died. Restarting.
[11-11-22 07:53:56.0728] main::init (354) Starting Logitech Media Server (v7.7.0, r33614, Tue Oct 18 11:07:25 PDT 2011) perl 5.010001
[11-11-22 07:53:56.5964] Slim::Networking::UDP::init (39) FATAL: There is already another copy of the Logitech Media Server running on this machine. (Address already in use)
[11-11-22 07:53:56.5978] Log::Log4perl::Logger::and_die (868) Warning: FATAL: There is already another copy of the Logitech Media Server running on this machine. (Address already in use) at /usr/share/squeezeboxserver/lib/Log/Log4perl/Logger.pm line 900
Comment 1 member 2011-11-24 00:26:16 UTC
As a workaround I have added a cron entry which monitors multiple squeezeboxservers and eventually kills them.
I suspect that there is a bug in /sbin/init.d/squeezeboxserver which relies only on /var/run/squeezeboxserver.pid instead of checking if other instances of squeezeboxserver are running.

Here is my workaround script. Maybe it somehow can help in fixing /sbin/init.d/squeezeboxserver.

SPIDfile=/var/run/squeezeboxserver.pid
[[ -f $SPIDfile ]] && SPID=$(cat $SPIDfile)

ps -C squeezeboxserver -o pid= -o ppid= \
  | grep -v -e "^ *$SPID " -e " $SPID$" \
  | awk '{print $1}' \
  | while read PID          # kill squeezeboxservers except if running with SPID
    do
        print "killing $PID"
        ps -p $PID > /dev/null && kill $PID
        sleep 1
        ps -p $PID > /dev/null && kill -9 $PID
        sleep 1
        ps -p $PID > /dev/null \
         && print "ERROR: could not kill $(ps -p $PID)"
    done
Comment 2 Kim Bach Petersen 2011-11-25 05:29:10 UTC
I have the same issue running Logitech Media Server Version: 7.7.0 - r33614 on an Ubuntu Server.

I not sure how the loop starts, but either rescanning the library and-or requesting a listing of albums, artists, etc. appears to be likely causes.

The log shows a pot like this for every 5 seconds or so:

2011-11-25 14:10:47 Logitech Media Server died. Restarting.
[11-11-25 14:10:50.0853] main::init (354) Starting Logitech Media Server (v7.7.0, r33614, Tue Oct 18 11:07:25 PDT 2011) perl 5.008008
[11-11-25 14:10:50.6651] Slim::Networking::UDP::init (39) FATAL: There is already another copy of the Logitech Media Server running on this machine. (Address already in use)
[11-11-25 14:10:50.6757] Log::Log4perl::Logger::and_die (868) Warning: FATAL: There is already another copy of the Logitech Media Server running on this machine. (Address already in use) at /usr/share/squeezeboxserver/lib/Log/Log4perl/Logger.pm line 900
Comment 3 Kim Bach Petersen 2011-11-25 05:57:57 UTC
The restart-loop also restarts even after a reboot, so it appears to be default behavior for LMS 7.7.0 - so I suggets the bug should be upgraded to 'critical' since it renders both the sqeezeserver and the actual hardware server useless due to full CPU-load.

Multiple - often as many as four - instances of squeezeboxserver are running continously right after boot, apparently some are shortlived others stays resident.
Comment 4 member 2011-11-27 01:16:12 UTC
I found that the new rev brought a new startup script /etc/init.d/logitechmediaserver which does the somewhat the same as the old previous /etc/init.d/squeezeboxserver.
Obviously the  'apt-get remove' which I did before updating to 7.7 did not check or remove the old startup scripts.
So whenever I rebooted my server the squeezeboxserver got started twice in error.

What made things worse was that the 2nd start did not properly account for the already running server but repeatedly started another server.

I did an update-rc.d -f squeezeboxserver remove and now things work properly again.
Comment 5 member 2011-11-27 06:32:14 UTC
Here is the brief summary for everybody who has the same problem due to the 2 startup entries:

# to list all startup entries do:
ls -l /etc/rc*.d/*  /etc/init.d/* | grep -i -e squeeze -e logitech  

# in case of dual startup do:
update-rc.d -f squeezeboxserver remove  # this removes the old startup entries

rm /etc/init.d/squeezeboxserver         # eventually remove the old init script                   


It appears to me as if someone has decided that squeezeboxserver is not appropriate anymore and a rebranding to logitechmediaserver should be done.
Unfortunately changing names of variables, services, config.files etc. is the number 1 source of software problems.
Comment 6 Kim Bach Petersen 2011-12-02 15:55:03 UTC
(In reply to comment #5)
> Here is the brief summary for everybody who has the same problem due to the 2
> startup entries:

Thanks a lot for sharing your solution and being so specific on what to do!