View Full Version : Colocar o folding como serviço em Linux
Vi este post no forum oficial do Folding
you can have it start up when Linux starts up and run in the background.
Login as root and make a folder such as FAH in the root directory. place the F@H console program there, run it to configure, and then exit.
now go into /etc/. there should be a file called rc.local or rc.boot (for mandrake, its rc.boot). add in a line that says:
cd /fah; /fah/FAH502-Linux.exe -local -forceasm -verbosity 9 -advmethods > /fah/myfah.log &
then it should run at startup and sigterm at shutdown.
Penso que se pode colocar como serviço a consola mas qual a vantagem de colocar assim?
Se aqui ninguém souber passo para o forum de Linux.
Eu estava interessado nisto para o Ubuntu:)
Olá Metro!
Andas muito Ubuntado :P (Hj chegaram os 10 cds do Ubuntu que tinha pedido o mes passado ;) vamos la ver quando instalo isto)
E assim, a vantagem de por como serviço, se serviço em linux for o mesmo que no windows se chama serviço, é mesmo sem estar com um user ligado, ele está a foldar.... imaginemos que eu ligo o meu pc, e de repente, lembro-me de uma reunião, nem tenho tempo para fazer login... O pc na pratica ta a foldar...
Acho que isto funciona melhor em servidores, em que toda a rede funciona sem estar um user com login... Assim, o folding está sempre a correr
Abraços!
um serviço basicamente é uma aplicação que corre aquando do Turnon do computador e é gerida pelo sistema operativo, sem qualquer intervenção humana. Corre de forma completamente transparente para o utilizador.
Isto é só pa Linux ou tb da pa windows?
Pocas
Isto é só pa Linux ou tb da pa windows?
Pocas
A consola para Windows já tem essa opção.
É logo das primeiras perguntas quando a configuras:
2.3 Launch automatically at machine statup, installing this a service (yes/no)? [no]
Marsupillami 21-07-2005, 16:05 Vi este post no forum oficial do Folding
Penso que se pode colocar como serviço a consola mas qual a vantagem de colocar assim?
Se aqui ninguém souber passo para o forum de Linux.
Eu estava interessado nisto para o Ubuntu:)
Eu coloquei assim num servidor que aqui tenho com dois Opterons. Já não me lembro ao certo porque tive de fazer isso, mas das duas uma:
- Ou não tinha a opção de correr como serviço.
- Ou se tinha não funcionava correctamente.
Sei que andei por aí à procura de como o fazer, vi uns scripts bastante "manhosos" mas no fim tudo se resume a criar um shell script e corrê-lo através do rc.local.
Fica aqui um link que poderá ajudar:
http://techreport.com/etc/folding/
Existe uma razão bastante importante para fazer isto. Por exemplo, este servidor é usado para alojamento de páginas WEB, pelo que ao iniciálo nem sequer faço login com nenhuma conta, fica simplesmente assim. Esporadicamente faço login para actualizações, etc, mas depois volto a sair. para não se ter o trabalho de estar sempre a correr o shell script é mais simples colocá-lo a correr em serviço quando o Linux está a iniciar os outros serviços, como por exemplo o MySQL e Apache (httpd).
Eu coloquei assim num servidor que aqui tenho com dois Opterons. Já não me lembro ao certo porque tive de fazer isso, mas das duas uma:
- Ou não tinha a opção de correr como serviço.
- Ou se tinha não funcionava correctamente.
Sei que andei por aí à procura de como o fazer, vi uns scripts bastante "manhosos" mas no fim tudo se resume a criar um shell script e corrê-lo através do rc.local.
Fica aqui um link que poderá ajudar:
http://techreport.com/etc/folding/
Existe uma razão bastante importante para fazer isto. Por exemplo, este servidor é usado para alojamento de páginas WEB, pelo que ao iniciálo nem sequer faço login com nenhuma conta, fica simplesmente assim. Esporadicamente faço login para actualizações, etc, mas depois volto a sair. para não se ter o trabalho de estar sempre a correr o shell script é mais simples colocá-lo a correr em serviço quando o Linux está a iniciar os outros serviços, como por exemplo o MySQL e Apache (httpd).
Bem-vindo ao nosso cantinho:)
Penso que é o teu primeiro post por aqui:)
Fiz quote da parte toda para ficar aqui para o futuro.
Folding under Linux
The Linux Folding@home client is command line-based only (no graphical client or screen saver).
The following instructions assume that you will be working from a command shell (terminal window). In most distros, you can launch a terminal window from the GUI by selecting System Tools - Terminal from the menus. If you are new to Linux, please note that command and file names in Linux are all case sensitive. On the other hand, if you're a Linux veteran, just bear with me (most of the following will probably be painfully obvious to you).
Basic client installation
To install the Folding@home client on a Linux system, you need to do the following:
1. Create a subdirectory in your home directory to put the Folding@home files in. I like to name the directory something descriptive... like folding.
2. Download the latest Linux client from Stanford's site and save it to the directory you created in step 1. The remaining instructions assume that you've downloaded the 5.02 client, FAH502-Linux.exe. If you have downloaded a newer client, substitute the appropriate file name in all of the instructions below.
3. Navigate to the folding directory (using the cd command), and enter the command: chmod +x FAH502-Linux.exe to mark the client as executable.
4. Run the client, and configure it. Assuming you are still in the folding directory, all you need to do is enter: ./FAH502-Linux.exe and the client should start. It prompts for your configuration options, just like the Windows console client does. Don't forget to enter 2630 as your team ID!
Once you have configured the client, it will continue to run in your terminal window. If you don't mind starting the client manually every time you log in, you're done. The client will stop when you log out; if you need to stop it manually for some reason, just hit ^C (control-C) in your terminal window. To start it up again, just navigate to your folding directory and enter: ./FAH502-Linux.exe If you'd like to automate things a bit more, read on...
Creating a script to launch the client in the background
You can easily create a script that will run the client as a background process. Using whatever plain text editor is bundled with your GUI (or vi if you're a seasoned UNIX hacker, or just plain masochistic), create the following text file:
#!/bin/bash
./FAH502-Linux.exe -forceasm >>folding.log 2>&1 &
I've included the -forceasm switch as an example; you can also specify any other switches you want to pass to the client. Save the above file to a short, easy to remember file name, like go. Also mark the file as executable, by entering the following command in your terminal window: chmod +x go. From now on, you can launch the client in the background simply by navigating to your folding directory, and typing: ./go
Running the client as a service
To have the folding client to start automatically when the system boots, you need to add it to your system's startup script. Under Redhat/Fedora, the startup script is located in the file /etc/rc.d/rc.local. This script is executed during system startup (well, actually during init level changes, but that discussion is beyond the scope of this article), after all other system initialization has been completed. Other distros may put it in a slightly different location, so if you don't see an rc.local script in the /etc/rc.d directory, you may need to poke around a bit, or do a little Googling to figure out where the appropriate file is located in your distro.
Once you've found the file, all you need to do is append the following line to the end of the rc.local script (you must be logged in as root to edit the rc.local script):
sudo -u joeblow sh -c "cd ~joeblow/folding; ./go"
(Substitute the actual name of the user under which the client is installed for joeblow.)
In a nutshell, this says "pretend we are user joeblow, go to his folding directory, and run the go script that is located there."
Odds and ends
OK, so you're running the Linux client in the background. Maybe you've even installed it as a service. How do you check on its status, or kill the client?
Checking on the status of the client is easy; just like the Windows version, everything the client does is logged in the FAHlog.txt file. You can examine the contents of that file to see what the client is doing. You can also use the tail -f command in a terminal window to continuously display the log file as it updates. The command:
cd ~/folding; tail -f FAHlog.txt
can be used in a terminal window to display a running log of what the client is doing, even if the client itself is running in the background.
The top command can be used in a terminal window to display a list of processes (similar to Windows' Task Manager). By default the display is sorted in descending order by CPU usage; unless the system is particularly busy, the Folding@home client should be near the top of the list.
To stop a client that is running as a background process or service, use the command:
killall FAH502-Linux.exe
You must be logged in as either the root user, or the user under which the client is running in order to kill it.
Fonte: http://techreport.com/etc/folding/
Asusta-me sempre usar um comando que se chama killall:D
Não me lembro se a versão mais recente da consola trás a opção de serviço. Às tantas trás e tudo isto é desnecessário. A proxima vez que instalar já vejo:)
Existe uma razão bastante importante para fazer isto. Por exemplo, este servidor é usado para alojamento de páginas WEB, pelo que ao iniciálo nem sequer faço login com nenhuma conta, fica simplesmente assim. Esporadicamente faço login para actualizações, etc, mas depois volto a sair. para não se ter o trabalho de estar sempre a correr o shell script é mais simples colocá-lo a correr em serviço quando o Linux está a iniciar os outros serviços, como por exemplo o MySQL e Apache (httpd). Foi mais ou menos o que eu disse :D Acho que isto funciona melhor em servidores, em que toda a rede funciona sem estar um user com login... Assim, o folding está sempre a correrMt resumido:P
Keep folding!
Marsupillami 21-07-2005, 18:54 Bem-vindo ao nosso cantinho:)
Penso que é o teu primeiro post por aqui:)
Fiz quote da parte toda para ficar aqui para o futuro.
Asusta-me sempre usar um comando que se chama killall:D
Não me lembro se a versão mais recente da consola trás a opção de serviço. Às tantas trás e tudo isto é desnecessário. A proxima vez que instalar já vejo:)
Obrigado pelas boas vinda Metro, na verdadejá andei aqui à uns anos atrás, quando ainda era Unreal e poucos mais eram que o Raptor, Petrus, Strakata, B_Back, Drak, etc...... usava outro nick pelo qual era conhecido na Madonion mas entretanto desenteressei-me um pouco mas ainda continuo a dar uma vista de olhos por cá ;).
Eu testei com a ultima versão do cliente. para parares o processor podes fazer um "ps ux", ves o pid e fazes "kill -9 pid" (sendo o pid o numero correspondente). Aquilo tem para lá muita texto, mas é bastante simples de fazer.
|
|