|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Jul 2002
Città: Novara
Messaggi: 8544
|
Far girare mldonkey come demone
Ciao a tutti!
Da poco ho risistemato il mio serverino/muletto. Ci ho messo debian testing con kernel 2.6 ricompilato e mi connetto dai vari client con ssh. Ho installato i binari precompilati di mldonkey nella home dell'utente "mldonkey", che ho creato per l'occasione, ed il programma è correttamente configurato e funziona alla grande. Accedo da remoto tramite interfaccia web sulla porta 4080, come è normale che sia con questo programma p2p. Il punto però è che io vorrei che il programma venisse avviato come demone, in modo da lanciarlo all'avvio o lanciarlo/stopparlo da ssh e poi spegnere il client e lasciarlo attivo sul server. Questo sistema funzionava egregiamente sulla distribuzione ipfrog che avevo in precedenza. Ho trovato uno script da installare in /etc/init.d , nella fattispecie questo: Codice:
#!/bin/sh # # MLDonkey start/stop script - (c) 2003 Lucas Peetz Dulley # # This is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # DESCRIPTION: # An useful and simple(?) script for starting, stopping and restarting # MLDonkey as a daemon. # # REQUIRES: # - bash, ps, wc, grep, awk and netcat. # # INSTALL: # - become root # - copy this file to /etc/init.d/ # - make the file executable "chmod +x /etc/init.d/MLDonkey" # - create links in the rc.* (in Debian: "update-rc.d MLDonkey defaults") # # USAGE: # - run "/etc/init.d/MLDonkey start" (to start) # - run "/etc/init.d/MLDonkey stop" (to stop) # - run "/etc/init.d/MLDonkey restart" (to restart) # ## BEGIN USER CONFIGURATION ## # # Set running directory and username (not root). MLDONKEYDIR=/full/path/to/mldonkey/directory/ USERNAME=username # # Set Netcat's (TCP/IP swiss army knife) filename - usually "nc" or "netcat" NETCAT=nc # ## END USER CONFIGURATION ## status() { PID=`ps ax -o "pid user command" | grep -E [[:space:]]\{3\}./mlnet | awk {'print $1'}` if [ $PID ];then if [ `ps -p $PID | wc -l` -eq 2 ]; then echo "mldonkey (pid $PID) running..." return 1 else echo "Stale PID" fi fi echo "mldonkey is stopped" return 0 } start() { # see if there is a mldonkey running status &> /dev/null if [ $? = 0 ]; then echo "Starting mldonkey:" cd $MLDONKEYDIR # Remove old servers rm -rf servers.ini* # Remove tmp files rm -rf *.tmp # Run MLDonkey su $USERNAME -c "nice -+19 ./mlnet -daemon &> /dev/null" fi return 0 } stop() { status &> /dev/null if [ $? = 1 ]; then echo "Stopping mldonkey:" cd $MLDONKEYDIR bash -c "$NETCAT 127.0.0.1 4000 <<STOPHERE close_fds kill STOPHERE" &> /dev/null sleep 10 return 0 fi return 1 } case "$1" in 'status') status ;; 'start') start ;; 'stop') stop ;; 'restart') stop start ;; *) echo "usage $0 start|stop|restart" exit 1 ;; esac exit $? ##-- eof Sapreste dirmi come far funzionare mldonkey (o magari qualsiasi programma) come demone? Vi ringrazio, buona domenica a tutti! |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Dec 2000
Messaggi: 1187
|
nohup nice -n 19 ./mlnet &
^D quando la shell termina, vengono brutalizzati solo i processi che hanno nice minore di un certo valore... v. man nice e man nohup |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Jul 2002
Città: Novara
Messaggi: 8544
|
Credo di non aver capito.. mi spieghi questo comando?
|
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Jul 2002
Città: Novara
Messaggi: 8544
|
uh, hai editato..
Spiega un momento che comando è e come funziona. Ho visto che va solo da root.. se lo lancio da utente non funziona. Com'è? |
![]() |
![]() |
![]() |
#5 |
Senior Member
Iscritto dal: Dec 2000
Messaggi: 1187
|
Veramente nohup e nice vanno da user, al limite pasta l'errore che da`...
|
![]() |
![]() |
![]() |
#6 | |
Senior Member
Iscritto dal: Jul 2002
Città: Novara
Messaggi: 8544
|
Quote:
Domani riprovo (al momento il server è spento, anche perchè sto facendo i preparativi per la ri-partenza). Comunque mi hai già fatto un grande regalo con questa stringa, ora devo leggermi un po' di pagine di man! ![]() Byez! |
|
![]() |
![]() |
![]() |
#7 |
Senior Member
Iscritto dal: Jul 2002
Città: Novara
Messaggi: 8544
|
ritiro tutto, funziona se lancio il programma dall'user che possiede i files.
(era un banale problema di permessi) Se poi voglio killare il processo qual è il modo corretto? Uccidere il core di mldonkey non svolge l'effetto sperato (resta un processo attivo). Devo dargli il kill manualmente? grazie! Ultima modifica di Cemb : 15-08-2005 alle 11:19. |
![]() |
![]() |
![]() |
#8 |
Senior Member
Iscritto dal: Dec 2000
Messaggi: 1187
|
ah gia`...
beh prova cosi` allora nohup nice -n 19 ./mlnet -daemon & |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 23:38.