| | 1028 | =head1 THE SCOREBOARD |
| | 1029 | |
| | 1030 | The scoreboards can be used to monitor what the TheSchwartz::Worker subclasses are |
| | 1031 | currently working on. Once the scoreboard has been enabled in the workers with |
| | 1032 | C<set_scoreboard> method the C<thetop> utility (shipped with TheSchwartz distribuition |
| | 1033 | in the C<extras> directory) can be used to list all current jobs being worked on. |
| | 1034 | |
| | 1035 | =head2 C<< $client->set_scoreboard( $dir ) >> |
| | 1036 | |
| | 1037 | Enables the scoreboard. Setting this to C<1> or C<on> will cause TheSchwartz to create |
| | 1038 | a scoreboard file in a location it determines is optimal. |
| | 1039 | |
| | 1040 | Passing in any other option sets the directory the TheSchwartz scoreboard directory should |
| | 1041 | be created in. For example, if you set this to C</tmp> then this would create a directory |
| | 1042 | called C</tmp/theschwartz> and a scoreboard file C</tmp/theschwartz/scoreboard.pid> in it |
| | 1043 | (where pid is the current process pid.) |
| | 1044 | |
| | 1045 | =head2 C<< $client->scoreboard() >> |
| | 1046 | |
| | 1047 | Returns the path to the current scoreboard file. |
| | 1048 | |
| | 1049 | =head2 C<< $client->start_scoreboard() >> |
| | 1050 | |
| | 1051 | Writes the current job information to the scoreboard file (called by the worker |
| | 1052 | in work_safely before it actually starts working) |
| | 1053 | |
| | 1054 | =head2 C<< $client->end_scoreboard() >> |
| | 1055 | |
| | 1056 | Appends the current job duration to the end of the scoreboard file (called by |
| | 1057 | the worker in work_safely once work has been completed) |
| | 1058 | |
| | 1059 | =head2 C<< $client->clean_scoreboard() >> |
| | 1060 | |
| | 1061 | Removes the scoreboard file (but not the scoreboard directory.) Automatically |
| | 1062 | called by TheSchwartz during object destruction (i.e. when the instance goes |
| | 1063 | out of scope) |
| | 1064 | |
| | 1065 | =head1 PASSING IN AN EXISTING DRIVER |
| | 1066 | |
| | 1067 | You can pass in a existing C<Data::Object::Driver::DBI> object which also allows you |
| | 1068 | to reuse exist Database handles like so: |
| | 1069 | |
| | 1070 | my $dbh = DBI->connect( $dsn, "root", "", { |
| | 1071 | RaiseError => 1, |
| | 1072 | PrintError => 0, |
| | 1073 | AutoCommit => 1, |
| | 1074 | } ) or die $DBI::errstr; |
| | 1075 | my $driver = Data::ObjectDriver::Driver::DBI->new( dbh => $dbh); |
| | 1076 | return TheSchwartz->new(databases => [{ driver => $driver }]); |
| | 1077 | |
| | 1078 | B<Note>: it's important that the C<RaiseError> and C<AutoCommit> flags are |
| | 1079 | set on the handle for various bits of functionality to work. |
| | 1080 | |
| | 1081 | |