aMule Forum

English => en_Bugs => Topic started by: ozsd on April 29, 2009, 12:50:53 PM

Title: amule not starting due to amulelock file
Post by: ozsd on April 29, 2009, 12:50:53 PM
I have configured amule to startup automatically at every session in the GNOME preferences. Also I usually never close amule before logging out, but I let the system close it when I logout/poweroff.

Sometimes it happens that at the next run amule won't start due to the amulelock file still present. Removing it and restarting amule works, but I am asking if there is a better way to avoid leaving the amulelock file or maybe a better way which amule could detect if it is already running (I know that many server applications use lock files, but even if the lock file is already present (e.g. after a system crash) the application can detect it and start fine: just to name one, the clamd antivirus daemon has the "FixStaleSocket" option, defaulting to true).

Thanks :)
Title: Re: amule not starting due to amulelock file
Post by: ozsd on May 07, 2009, 02:00:24 PM
It's just happened again, and no, there are not other instances running:

Code: [Select]
ozsd@bdf:~$ ps -ef | grep amule
ozsd    11587  3883  0 13:55 pts/0    00:00:00 grep --color=auto amule
ozsd@bdf:~$ amule
Initialising aMule 2.2.4 using wxGTK2 v2.8.9
Checking if there is an instance already running...
There is an instance of aMule already running
(lock file: /home/ozsd/.aMule/muleLock)Raising current running instance.
$ cat .aMule/muleLock
3703ozsd@bdf:~$ ps -ef | grep amule
ozsd    12183  3883  0 14:18 pts/0    00:00:00 grep --color=auto amule

The log file has nothing interesting (only connections details of previous session).
Title: Re: amule not starting due to amulelock file
Post by: ozsd on May 20, 2009, 06:19:14 PM
You'd better looking at 

Code: [Select]
ps -f $(cat ~/.aMule/muleLock)
 so that to understand what is the process locking amule.

OK, the problem reappeared, there is no other process with that PID:
Code: [Select]
ozsd@bdf:~$ cat ~/.aMule/muleLock
4024ozsd@bdf:~$ ps -f $(cat ~/.aMule/muleLock)
UID        PID  PPID  C STIME TTY      STAT   TIME CMD
ozsd@bdf:~$ amule
Initialising aMule 2.2.5 using wxGTK2 v2.8.9
Checking if there is an instance already running...
There is an instance of aMule already running
(lock file: /home/fabio/.aMule/muleLock)Raising current running instance.
ozsd@bdf:~$ ps -f $(cat ~/.aMule/muleLock)
UID        PID  PPID  C STIME TTY      STAT   TIME CMD
ozsd@bdf:~$

this is my logfile of previous session:
Code: [Select]
2009-05-20 17:24:33: Starting aMule 2.2.5 using wxGTK2 v2.8.9
2009-05-20 17:24:34: Il file dei crediti è stato caricato, 645 client conosciuti
2009-05-20 17:24:34: Carico i filtri IP da 'ipfilter.dat' e 'ipfilter_static.dat'.
2009-05-20 17:24:45: Caricati 265353 intervalli di IP da '/home/ozsd/.aMule/ipfilter.dat'. 0 righe non valide sono state scartate.
2009-05-20 17:24:45: Caricati 0 intervalli di IP da '/home/ozsd/.aMule/ipfilter_static.dat'. 0 righe non valide sono state scartate.
2009-05-20 17:24:45: Connessioni esterne disabilitate nel file di configurazione
2009-05-20 17:24:45: Created Server UDP-Socket at port 4665
2009-05-20 17:24:45: Created Client UDP-Socket at port 4672
2009-05-20 17:24:46:
2009-05-20 17:24:46:  - Questo è aMule 2.2.5 using wxGTK2 v2.8.9 basato su eMule.
2009-05-20 17:24:46:    In esecuzione su Linux 2.6.28-11-generic i686
2009-05-20 17:24:46:  - Visita http://www.amule.org per sapere se è disponibile una nuova versione.
2009-05-20 17:24:46:
2009-05-20 17:24:47: Caricati 248 flag bitmap.
2009-05-20 17:24:48: Caricamento file server.met: /home/ozsd/.aMule/server.met
2009-05-20 17:24:48: Trovati 4 server nel file server.met
2009-05-20 17:24:48: Trovati 2 file parziali
2009-05-20 17:24:48: Trovati 3 file condivisi conosciuti
2009-05-20 17:24:48: Connessione in corso
2009-05-20 17:24:48: Connessione a eDonkeyServer No2 (212.63.206.35 - 212.63.206.35:4242) utilizzo offuscamento del protocollo.
2009-05-20 17:24:48: Letti 144 contatti Kad
2009-05-20 17:24:48: Deleted stale lock file '/home/ozsd/.aMule/muleLock'.
2009-05-20 17:24:48: La tua copia di aMule è aggiornata.
2009-05-20 17:24:48: Connessione a Sharing Kingdom 2 (89.248.172.50 - 89.248.172.50:4500) utilizzo offuscamento del protocollo.
2009-05-20 17:24:48: Persa connessione a eDonkeyServer No2 (212.63.206.35:4242)
2009-05-20 17:24:48: Connessione persa
2009-05-20 17:24:48: Kad avviato.
2009-05-20 17:24:48: Connesso a Sharing Kingdom 2 (89.248.172.50:4500)
2009-05-20 17:24:49: Kad arrestato.
2009-05-20 17:24:49: Connesso alla rete Kad (firewalled)
2009-05-20 17:24:49: ThreadScheduler: Completed task 'AICH Syncronizing', 0 tasks remaining.
2009-05-20 17:24:57: Connessione a eDonkeyServer No2 (212.63.206.35:4242) non riuscita per time-out.
2009-05-20 17:24:57: Connessione a Sharing Kingdom 1 (89.248.172.54 - 89.248.172.54:4500) utilizzo offuscamento del protocollo.
2009-05-20 17:24:57: Connesso a Sharing Kingdom 1 (89.248.172.54:4500)
2009-05-20 17:24:59: ATTENZIONE: Sharing Kingdom 2 (89.248.172.50:4500) - NG : You have a lowid. Please review your network config and/or your settings.
2009-05-20 17:24:59: Connessione stabilita con: Sharing Kingdom 2
2009-05-20 17:24:59: Connesso a Sharing Kingdom 2 con ID basso
2009-05-20 17:24:59: Il nuovo clientID è 353612
2009-05-20 17:24:59: ATTENZIONE: hai ricevuto un ID basso!
2009-05-20 17:24:59: Probabilmente perché il tuo pc è dietro un firewall o router.
2009-05-20 17:24:59: Per altre informazioni visita http://wiki.amule.org
2009-05-20 17:24:59: Messaggio del server: server version 17.15 (lugdunum)
2009-05-20 17:24:59: Messaggio del server: GRATUITA  www.StormSex.net  VIDEO E FOTO XXX: Le piu' belle ragazze d'europa si esibiscono per voi !!! www.StormSex.net GRATUITA
2009-05-20 17:24:59: Messaggio del server: GRATUITA  www.StormSex.net  VIDEO E FOTO XXX: Le piu' belle ragazze d'europa si esibiscono per voi !!! www.StormSex.net GRATUITA
2009-05-20 17:24:59: Messaggio del server: GRATUITA  www.StormSex.net  VIDEO E FOTO XXX: Le piu' belle ragazze d'europa si esibiscono per voi !!! www.StormSex.net GRATUITA
2009-05-20 17:24:59: Messaggio del server: GRATUITA  www.StormSex.net  VIDEO E FOTO XXX: Le piu' belle ragazze d'europa si esibiscono per voi !!! www.StormSex.net GRATUITA ex.net GRATUITA ex.net
Title: Re: amule not starting due to amulelock file
Post by: gav616 on May 21, 2009, 12:17:15 AM
im on a BSD type nix (arch) and my amuled is through a 'rc.d' script i.e. (start, stop, restart)

i used to get the 'muleLock'  when I shut-down amule too fast, soo in my script i left amule longer to shutdown connections before killing it.

TBH i would always manually run the 'stop' cmd on your amuled just to be sure it 'kills' correctly before you shutdown or reboot, and i would always manually 'start' amuled.
 
thus;
Code: [Select]
#!/bin/bash

if [ "$(id -u)" != 0 ]
then
echo "You must be root to start aMule as daemon."
exit 2
fi

# general config
USECOLOR="YES"
. /etc/conf.d/amule.conf
. /etc/rc.d/functions

if [ -z $AMULEUSER ]
then
echo "Unable to run aMule. You must set the user in /etc/conf.d/amule.conf."
exit 2
elif [[ $AMULEUSER == "root" ]]
then
echo "Unable to run aMule. You must not run aMule as root."
exit 2
fi

confdir=$(su -l $AMULEUSER -c "echo ~")/.aMule
logfile=$(su -l $AMULEUSER -c "echo ~")/.aMule/amuled.log
lockfile=$(su -l $AMULEUSER -c "echo ~")/.aMule/muleLock

PID=`pidof -o %PPID /usr/bin/amuled`

[ -f $logfile ] && rm -f $logfile

case "$1" in
    start)
        stat_busy "Starting aMule"

if [ -f $lockfile ]
then
stat_fail
echo "Unable to run aMule, it is already running. If you're sure aMule is not already running, you can remove ${lockfile}."
exit 2
fi

[ ! -d $confdir ] && su -l $AMULEUSER  -c "mkdir -p $confdir"

[ -z "$PID" ] && su -l $AMULEUSER -c "/usr/bin/amuled -o &> $logfile &"

i=0

while [ "$i" -lt 20 ]
do
if [ ! -z "$(grep "No other instances are running." $logfile)" ]
then
add_daemon amule
stat_done
exit 0
elif [ ! -z "$(grep "There seems to be an instance of aMule already running" $logfile)" ]
then
stat_fail
exit 2
else
i="$(($i+1))"
fi
sleep 1
done
stat_fail
        ;;
    stop)
        stat_busy "Stopping aMule"
if [ -f $lockfile ]
then
[ ! -z "$PID" ]  && kill $PID &> /dev/null
else
stat_fail
echo "Unable to stop aMule. It is not running."
exit 2
fi
        if [ $? -gt 0 ]; then
            stat_fail
        else
            rm_daemon amule
            stat_done
        fi
sleep 10
        ;;
    restart)
        $0 stop
sleep 1
        $0 start
        ;;
    *)
        echo "usage: $0 {start|stop|restart}"
;;
esac
exit 0
Title: Re: amule not starting due to amulelock file
Post by: Kry on May 21, 2009, 04:35:25 AM
If you're planning on killing the daemon, you might as well remove the lock file yourself. Killing it is not the way to close it.
Title: Re: amule not starting due to amulelock file
Post by: ozsd on May 21, 2009, 09:56:48 AM
There's something weird.

You know aMule stores its configuration file in the ~/.aMule directory.
When you launch it as 'oszd' user, I expect the lock file is ~/.aMule/muleLock , likely "/home/oszd/.aMule/muleLock"

I see that in your case the muleLock fetched is "/home/fabio/.aMule/muleLock" which is about another user..... and God knows what process PID helds.

Can it be  the amule.conf file of the oszd user (~oszd/.aMule/amule.conf) is broken , and incorrectly defines /home/fabio/.aMule as the configuration directory?

Uh, sorry, my bad. That fabio-ozsd mismatch was only a cut and paste error. Ignore that.
Title: Re: amule not starting due to amulelock file
Post by: ozsd on May 28, 2009, 11:01:35 AM
ozsd, as you let the the system close amule at shutdown, I think gav616 pointed out the problem.

Normal shutdown procedures don't give enough time to amule to properly close (save all files etc.)
In that case , the muleLock file is not deleted, and sometimes,  at the next restart, the PID file stored in the lock file is re-used by some short-living process . Consequently, your random problem.
I think it's unlikely that the previous amule PID is used by other short-living processes, it could be for the first automatically amule run, but I then tried several time restarting amule and never worked until I deleted the lock file.
Quote
And perhaps, in your situation, it's better running amuled (the daemon) outside Gnome.

I am stick to the idea.
Running the daemon, you can let the system handle it in usual startup/shutdown procedures (http://www.amule.org/wiki/index.php/FAQ_amuled), specifying how much time the system should wait before a 'kill -9' is forced. For example, I own a slow VIA C3 system , and I force up to 90 seconds close wait in such script.

OK, that would be indeed the ideal solution.

Thanks!