| 1 | # | ||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||
| 3 | # | ||
| 4 | # vim: set ts=3 sw=3 tw=0: | ||
| 5 | # vim: set expandtab: | ||
| 6 | |||
| 7 | package Rex::Gearman; | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use warnings; | ||
| 11 | |||
| 12 | our $VERSION = "0.32.0"; | ||
| 13 | |||
| 14 | 1; | ||
| 15 | |||
| 16 | =head1 Rex::Gearman - Distributed Rex | ||
| 17 | |||
| 18 | Distibuted Rex is a addition to Rex for distributed Task execution with the help of gearman. So it is possible to scale rex. | ||
| 19 | |||
| 20 | Distributed Rex is setup of two components. One (or more) Worker and one Client. As more worker you run as more parallel tasks you are able to execute. | ||
| 21 | |||
| 22 | =head1 INSTALLATION | ||
| 23 | |||
| 24 | To install Distributed Rex you have to follow these steps. | ||
| 25 | |||
| 26 | |||
| 27 | =head2 On the Client | ||
| 28 | |||
| 29 | First you have to add the Rex repository to your package manager. To do this read L<http://rexify.org/get/>. | ||
| 30 | |||
| 31 | Now you can install Distributed Rex via your package manager. On Debian or Ubuntu you can use I<apt>. | ||
| 32 | |||
| 33 | apt-get install rex-gearman | ||
| 34 | |||
| 35 | If you want to install it via CPAN you can do this easily with cpanm. | ||
| 36 | |||
| 37 | cpanm Rex::Gearman | ||
| 38 | |||
| 39 | or | ||
| 40 | |||
| 41 | curl -L get.rexify.org | perl - --sudo -n Rex::Gearman | ||
| 42 | |||
| 43 | =head2 On the server (worker) | ||
| 44 | |||
| 45 | First you have to install gearman, configure it to listen not only on the loopback device and start it. | ||
| 46 | |||
| 47 | Than you can install Distributed Rex. On Debian or Ubuntu you can use I<apt>. | ||
| 48 | |||
| 49 | apt-get install rex-gearman | ||
| 50 | |||
| 51 | If you want to install it via CPAN you can do this easily with cpanm. | ||
| 52 | |||
| 53 | cpanm Rex::Gearman | ||
| 54 | |||
| 55 | or | ||
| 56 | |||
| 57 | curl -L get.rexify.org | perl - --sudo -n Rex::Gearman | ||
| 58 | |||
| 59 | |||
| 60 | After that you have to distribute your Rexfile (and all associated files (like templates, the "lib" directory, ssh keys, ...) to your worker machines. We recommend to name the directory where you put the Rexfile the same as on your client machine. | ||
| 61 | |||
| 62 | Example directory structure on the client: | ||
| 63 | |||
| 64 | /home/user/projects/frontend | ||
| 65 | |-- Rexfile | ||
| 66 | |-- client.conf | ||
| 67 | +-- lib | ||
| 68 | | +-- Rex | ||
| 69 | | +-- Webserver | ||
| 70 | | +-- Apache.pm | ||
| 71 | | +-- templates | ||
| 72 | | +-- httpd.conf | ||
| 73 | +-- worker.conf | ||
| 74 | |||
| 75 | Example directory structure on the server/worker machine: | ||
| 76 | |||
| 77 | /opt/rex/frontend | ||
| 78 | |-- Rexfile | ||
| 79 | |-- client.conf | ||
| 80 | +-- lib | ||
| 81 | | +-- Rex | ||
| 82 | | +-- Webserver | ||
| 83 | | +-- Apache.pm | ||
| 84 | | +-- templates | ||
| 85 | | +-- httpd.conf | ||
| 86 | +-- worker.conf | ||
| 87 | |||
| 88 | Now change into the directory where your I<Rexfile> is located and create a file I<worker.conf>. | ||
| 89 | |||
| 90 | Here you have to configure all your gearmand servers so that the Worker module can register its functions to them. | ||
| 91 | |||
| 92 | { | ||
| 93 | job_servers => [ | ||
| 94 | "127.0.0.1:4730", | ||
| 95 | "192.168.7.10:4730", | ||
| 96 | "192.168.7.11:4730", | ||
| 97 | ], | ||
| 98 | }; | ||
| 99 | |||
| 100 | Now you are able to start the workerprocess. | ||
| 101 | |||
| 102 | rex-gearman-worker -d | ||
| 103 | |||
| 104 | =head1 RUNNING A TASK | ||
| 105 | |||
| 106 | Switch back to your workstation / the client. | ||
| 107 | |||
| 108 | Change to the directory where your I<Rexfile> lives and create a file called I<client.conf>. In this file you have to configure your gearmand servers. | ||
| 109 | |||
| 110 | { | ||
| 111 | job_servers => [ | ||
| 112 | "127.0.0.1:4730", | ||
| 113 | "192.168.7.10:4730", | ||
| 114 | "192.168.7.11:4730", | ||
| 115 | ], | ||
| 116 | }; | ||
| 117 | |||
| 118 | |||
| 119 | Now you're able to run your tasks as known. But you have to replace the I<rex> command with I<rex-gearman-client>. The CLI parameter are the same. So you can use I<rex-gearman-client> the same way as you used I<rex>. | ||
| 120 | |||
| 121 | For example: | ||
| 122 | |||
| 123 | rex-gearman-client -h | ||
| 124 | rex-gearman-client -Tv | ||
| 125 | rex-gearman-client prepare | ||
| 126 | |||
| 127 | |||
| 128 | =head1 REPORTING BUGS | ||
| 129 | |||
| 130 | Please report the bugs in the Issue-Tracker. | ||
| 131 | |||
| 132 | =head1 GETTING HELP | ||
| 133 | |||
| 134 | If you need help, you can join us on irc on irc.freenode.net channel #rex. | ||
| 135 | |||
| 136 | |||
| 137 |