New upstream version 1.1.15
Alexandre Mestiashvili
7 years ago
11 | 11 | packages: |
12 | 12 | - gcc-4.9 |
13 | 13 | - g++-4.9 |
14 | artifacts: true | |
14 | 15 | env: COMPILER=g++-4.9 |
15 | 16 | - compiler: gcc |
16 | 17 | addons: |
20 | 21 | packages: |
21 | 22 | - gcc-5 |
22 | 23 | - g++-5 |
24 | artifacts: true | |
23 | 25 | env: COMPILER=g++-5 |
24 | 26 | |
25 | 27 | before_install: |
556 | 556 | Arguments: |
557 | 557 | - None. |
558 | 558 | |
559 | prioritystatus | |
560 | ||
561 | This sends back a list of all registered functions. Next to each | |
562 | function is the number of queued jobs that are not running, broken down | |
563 | by priority, and the number of capable workers. The columns are tab | |
564 | separated, and the list is terminated with a line containing | |
565 | a single '.' (period). The format is: | |
566 | ||
567 | FUNCTION\tHIGH-QUEUED\tNORMAL-QUEUED\tLOW-QUEUED\tAVAILABLE_WORKERS | |
568 | ||
569 | Columns: | |
570 | - Function name. | |
571 | - Number of queued high priority jobs. | |
572 | - Number of queued normal priority jobs. | |
573 | - Number of queued low priority jobs. | |
574 | - Available workers registered for this function. | |
575 | ||
576 | Arguments: | |
577 | - None. | |
578 | ||
559 | 579 | maxqueue |
560 | 580 | |
561 | 581 | This sets the maximum queue size for a function. If no size is |
570 | 590 | - Optional maximum queue size (to apply one maximum at all priorities), or |
571 | 591 | three optional maximum queue sizes (to enforce for high-, normal-, and |
572 | 592 | low-priority job submissions). |
573 | ||
574 | shutdown | |
575 | ||
576 | Shutdown the server. If the optional "graceful" argument is used, | |
577 | close the listening socket and let all existing connections | |
578 | complete. | |
579 | ||
580 | Arguments: | |
581 | - Optional "graceful" mode. | |
582 | 593 | |
583 | 594 | version |
584 | 595 |
0 | Hi! | |
1 | ||
2 | You've most likely downloaded this package as a tar.gz distribution, | |
3 | so you'll want to read Getting Started. If you are interested in | |
4 | developing or submitting patches to the project, read the Contributing | |
5 | and Coding Style sections. | |
6 | ||
7 | ||
8 | Getting Started | |
9 | --------------- | |
10 | ||
11 | You can grab a released version of Gearman from https://github.com/gearman/gearmand/. If you want to work on the latest code, please read the file HACKING. | |
12 | ||
13 | To build, you can follow the normal: | |
14 | ||
15 | ./configure | |
16 | make | |
17 | make install | |
18 | ||
19 | You can also run 'make test' before installing to make sure everything | |
20 | checks out ok. Once you have it installed, you can start the Gearman | |
21 | job server with: | |
22 | ||
23 | gearmand -v | |
24 | ||
25 | This will start it while printing some verbose messages. To try | |
26 | running a job through it, look in the examples/ directory of this | |
27 | source and run: | |
28 | ||
29 | ./reverse_worker | |
30 | ||
31 | Once that is running, you can run your first job with: | |
32 | ||
33 | ./reverse_client "Hello, Gearman!" | |
34 | ||
35 | If all goes well, the reverse_worker application should have output: | |
36 | ||
37 | Job=H:lap:1 Workload=Hello, Gearman! Result=!namraeG ,olleH | |
38 | ||
39 | While the reverse_client returned: | |
40 | ||
41 | Result=!namraeG ,olleH | |
42 | ||
43 | If you want to start writing your own client and workers, be sure to | |
44 | check out the developer API at: | |
45 | ||
46 | http://gearman.info/libgearman.html | |
47 | ||
48 | You can also find other useful resources related to the project at: | |
49 | ||
50 | http://www.gearman.org/ | |
51 | ||
52 | Enjoy! | |
53 | ||
54 | ||
55 | Contributing | |
56 | ------------ | |
57 | ||
58 | If you are getting this code from https://github.com/gearman/gearmand | |
59 | then continue reading. Otherwise these directions are not for you | |
60 | (well maybe...). | |
61 | ||
62 | To obtain code from Github you will need to | |
63 | issue the following command: | |
64 | ||
65 | git clone https://github.com/gearman/gearmand | |
66 | ||
67 | Once the tree is branched you will need to build the "configure" | |
68 | script. You can do this by running the script: | |
69 | ||
70 | ./bootstrap.sh -a | |
71 | ||
72 | It will set up all of the files you need to build the package. At | |
73 | that point it is just the typical "./configure; make; make test; | |
74 | make install" | |
75 | ||
76 | For a tarball release do a "make dist" and for an RPM type "make rpm". | |
77 | ||
78 | For patches please create a branch on github and propose it to be | |
79 | merged into the trunk. You can find out more information on how to | |
80 | do this at the github help site: | |
81 | ||
82 | https://help.github.com/articles/creating-a-pull-request/ | |
83 | ||
84 | ||
85 | Thanks and keep hacking! | |
86 | ||
87 | Cheers, | |
88 | -Brian | |
89 | Seattle, WA. |
0 | 0 | gearmand |
1 | 1 | ======== |
2 | 2 | |
3 | [![Build Status](https://travis-ci.org/p-alik/gearmand.png)](https://travis-ci.org/p-alik/gearmand) | |
3 | [![Build Status](https://travis-ci.org/gearman/gearmand.png)](https://travis-ci.org/gearman/gearmand) | |
4 | 4 | |
5 | this repository is a fork of [launchpad repository](http://launchpad.net/gearmand/) which seems to be orphaned | |
5 | The latest version of ```gearmand``` source code and versions 1.1.13 and later can be found at: [Github Repository](https://github.com/gearman/gearmand). Older versions released before 1.1.13 can be found at: [Launchpad Repository](http://launchpad.net/gearmand/) | |
6 | 6 | |
7 | You can grab the latest release distribution of Gearman from https://github.com/gearman/gearmand/releases | |
8 | ||
9 | Hi! | |
10 | ||
11 | What is Gearman? | |
12 | ||
13 | Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work. It allows you to do work in parallel, to load balance processing, and to call functions between languages. Gearman is the nervous system for how distributed processing communicates. | |
14 | ||
15 | If you downloaded this package as a ```tar.gz``` distribution you'll want to read ***Getting Started*** section below or visit the more detailed web page [Getting Started](http://gearman.org/getting-started/) | |
16 | ||
17 | If you are interested in developing or submitting patches to the project, read the ***Contributing*** section below and check out the [HACKING](https://github.com/gearman/gearmand/blob/master/HACKING) file for ***Coding Style*** and [COPYING](https://github.com/gearman/gearmand/blob/master/COPYING) for details on ***licensing***. | |
18 | ||
19 | Getting Started | |
20 | --------------- | |
21 | ||
22 | ||
23 | If you want to work on the latest code, please read the file [HACKING](https://github.com/gearman/gearmand/blob/master/HACKING). | |
24 | ||
25 | To build a release version from a tarball (```.tar.gz``` or ```.tgz```), you can follow the normal: | |
26 | ||
27 | Change into the directory where you saved the tarball and run: | |
28 | ||
29 | tar xzf gearmand-X.Y.tar.gz | |
30 | cd gearmand-X.Y | |
31 | ||
32 | Then run the usual autoconfigure style build (you may need to use ```sudo``` to install): | |
33 | ||
34 | ./configure | |
35 | make | |
36 | make install | |
37 | ||
38 | You can also run ```make test``` before installing to make sure everything | |
39 | checks out ok. You can also streamline the process of building and testing by running: | |
40 | ||
41 | ./configure && make && make test | |
42 | make install | |
43 | ||
44 | Once you have it installed, you can start the Gearman job server with: | |
45 | ||
46 | gearmand -v | |
47 | ||
48 | This will start it while printing some verbose messages. To try | |
49 | running a job through it, look in the examples/ directory of this | |
50 | source and run: | |
51 | ||
52 | ./reverse_worker | |
53 | ||
54 | Once that is running, you can run your first job with: | |
55 | ||
56 | ./reverse_client "Hello, Gearman!" | |
57 | ||
58 | If all goes well, the reverse_worker application should have output: | |
59 | ||
60 | Job=H:lap:1 Workload=Hello, Gearman! Result=!namraeG ,olleH | |
61 | ||
62 | While the reverse_client returned: | |
63 | ||
64 | Result=!namraeG ,olleH | |
65 | ||
66 | There are a lot more details about gearmand at: [Getting Started](http://gearman.org/getting-started/) | |
67 | ||
68 | If you want to start writing your own client and workers, be sure to check out the [Developer API](http://gearman.info/libgearman.html) documentation. | |
69 | ||
70 | There are also many other [Useful Resources](http://www.gearman.org/) to help you put gearmand to work for you! | |
71 | ||
72 | Enjoy! | |
73 | ||
74 | ||
75 | Contributing | |
76 | ------------ | |
77 | ||
78 | The current versions of geamand are maintained on our [Github Repo for gearmand](https://github.com/gearman/gearmand) | |
79 | ||
80 | Not everyone is familiar with ```git```, so you can find more info at [Getting Started with Git](https://git-scm.com/book/en/v1/Getting-Started) | |
81 | ||
82 | Please follow these instructions to clone, create a branch and generate a pull request on that branch. More details on using github to do this can be found in []() | |
83 | ||
84 | 1. clone the github repository into your local file system: | |
85 | ||
86 | git clone https://github.com/gearman/gearmand | |
87 | ||
88 | 2. Next, think of a clear, descriptive branch name and then create a new branch and change to it: | |
89 | ||
90 | git checkout -b DESCRIPTIVE_BRANCH_NAME | |
91 | ||
92 | 3. Once the tree is branched you will need to generate the "configure" script for autoconfigure. | |
93 | ||
94 | ./bootstrap.sh -a | |
95 | ||
96 | 4. Finally! you are ready to run tests, make changes to the code and generate a pull request on your branch so we can consider your changes. | |
97 | ||
98 | You can learn more about how to Create a Pull Request](https://help.github.com/articles/creating-a-pull-request/) and [Create a Pull Request from a Fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) | |
99 | ||
100 | ||
101 | But Wait! There's More! | |
102 | ----------------------- | |
103 | ||
104 | Once you have made your changes there are two additional ```make``` targets to build release ready distributions: | |
105 | ||
106 | To generate a tarball distribution of your code: | |
107 | ||
108 | make dist | |
109 | ||
110 | Or to gerate an RPM distribution use: | |
111 | ||
112 | make rpm | |
113 | ||
114 | Thanks and keep hacking! | |
115 | ||
116 | Cheers, | |
117 | -Brian | |
118 | Seattle, WA. |
142 | 142 | ("show-jobs", "Show all jobs on the server.") |
143 | 143 | ("getpid", "Get Process ID for the server.") |
144 | 144 | ("status", "Status for the server.") |
145 | ("priority-status", "Queued jobs status by priority.") | |
145 | 146 | ("workers", "Workers for the server.") |
146 | ("shutdown", "Shutdown server.") | |
147 | 147 | ("ssl,S", "Enable SSL connections.") |
148 | 148 | ; |
149 | 149 | |
183 | 183 | vm.count("show-jobs") == 0 and |
184 | 184 | vm.count("getpid") == 0 and |
185 | 185 | vm.count("status") == 0 and |
186 | vm.count("workers") == 0 and | |
187 | vm.count("shutdown") == 0) | |
186 | vm.count("priority-status") == 0 and | |
187 | vm.count("workers") == 0) | |
188 | 188 | { |
189 | 189 | std::cout << "No option execution operation given." << std::endl << std::endl; |
190 | 190 | std::cout << desc << std::endl; |
191 | 191 | return EXIT_FAILURE; |
192 | 192 | } |
193 | 193 | |
194 | if (vm.count("shutdown")) | |
195 | { | |
196 | instance.push(new util::Operation(util_literal_param("shutdown\r\n"))); | |
197 | } | |
198 | 194 | |
199 | 195 | if (vm.count("status")) |
200 | 196 | { |
201 | 197 | instance.push(new util::Operation(util_literal_param("status\r\n"))); |
198 | } | |
199 | ||
200 | if (vm.count("priority-status")) | |
201 | { | |
202 | instance.push(new util::Operation(util_literal_param("prioritystatus\r\n"))); | |
202 | 203 | } |
203 | 204 | |
204 | 205 | if (vm.count("workers")) |
257 | 258 | |
258 | 259 | if (not instance.run()) |
259 | 260 | { |
260 | /* shutdown will produce a read error since nothing is read */ | |
261 | if (not vm.count("shutdown")) | |
262 | { | |
263 | std::cerr << "Error: " << instance.last_error() << std::endl; | |
264 | return EXIT_FAILURE; | |
265 | } | |
261 | /* will produce a read error since nothing is read */ | |
262 | std::cerr << "Error: " << instance.last_error() << std::endl; | |
263 | return EXIT_FAILURE; | |
266 | 264 | } |
267 | 265 | |
268 | 266 | return EXIT_SUCCESS; |
0 | #!/bin/bash | |
0 | #!/usr/bin/env bash | |
1 | 1 | # |
2 | 2 | # Copyright (C) 2012-2013 Brian Aker |
3 | 3 | # All rights reserved. |
311 | 311 | VENDOR='suse' |
312 | 312 | ;; |
313 | 313 | *) |
314 | die "An attempt was made to set an invalid VENDOR=$_vendor" | |
314 | die "An attempt was made to set an invalid VENDOR=$vendor" | |
315 | 315 | ;; |
316 | 316 | esac |
317 | 317 |
45 | 45 | |
46 | 46 | Workers for the server. |
47 | 47 | |
48 | .. option:: --shutdown | |
49 | ||
50 | Shutdown server. | |
51 | ||
52 | 48 | |
53 | 49 | ----------- |
54 | 50 | DESCRIPTION |
41 | 41 | |
42 | 42 | Return the process id of the server. |
43 | 43 | |
44 | .. describe:: shutdown | |
45 | ||
46 | Tell the server to shutdown. | |
47 | ||
48 | 44 | .. describe:: verbose |
49 | 45 | |
50 | 46 | Change the verbose level of the server. |
598 | 598 | { |
599 | 599 | Client* client= client_shell->impl(); |
600 | 600 | |
601 | if (gearman_connection_create(client->universal, host, port) == false) | |
601 | if (gearman_connection_create(client->universal, host, port) == NULL) | |
602 | 602 | { |
603 | 603 | assert(client->error_code() != GEARMAN_SUCCESS); |
604 | 604 | return client->error_code(); |
613 | 613 | |
614 | 614 | gearman_return_t Client::add_server(const char *host, const char* service_) |
615 | 615 | { |
616 | if (gearman_connection_create(universal, host, service_) == false) | |
616 | if (gearman_connection_create(universal, host, service_) == NULL) | |
617 | 617 | { |
618 | 618 | assert(error_code() != GEARMAN_SUCCESS); |
619 | 619 | return error_code(); |
92 | 92 | |
93 | 93 | std::string server; |
94 | 94 | std::string service; |
95 | std::string password; | |
95 | 96 | |
96 | 97 | private: |
97 | 98 | redisContext *_redis; |
105 | 106 | { |
106 | 107 | command_line_options().add_options() |
107 | 108 | ("redis-server", boost::program_options::value(&server), "Redis server") |
108 | ("redis-port", boost::program_options::value(&service), "Redis server port/service"); | |
109 | ("redis-port", boost::program_options::value(&service), "Redis server port/service") | |
110 | ("redis-password", boost::program_options::value(&password), "Redis server password/service"); | |
109 | 111 | } |
110 | 112 | |
111 | 113 | Hiredis::~Hiredis() |
121 | 123 | GEARMAN_DEFAULT_LOG_PARAM, |
122 | 124 | GEARMAND_QUEUE_ERROR, |
123 | 125 | "Could not connect to redis server: %s", _redis->errstr); |
126 | } | |
127 | ||
128 | if (password.size()) | |
129 | { | |
130 | redisReply *reply = (redisReply*)redisCommand(_redis, "AUTH %s", password.c_str()); | |
131 | if(reply == NULL) | |
132 | { | |
133 | return gearmand_log_gerror( | |
134 | GEARMAN_DEFAULT_LOG_PARAM, | |
135 | GEARMAND_QUEUE_ERROR, | |
136 | "Failed to exec AUTH command, redis server reply: %s", _redis->errstr); | |
137 | } | |
138 | ||
139 | if(reply->type == REDIS_REPLY_ERROR) | |
140 | { | |
141 | gearmand_log_gerror( | |
142 | GEARMAN_DEFAULT_LOG_PARAM, | |
143 | GEARMAND_QUEUE_ERROR, | |
144 | "Could not pass redis server auth, redis server reply: %s", reply->str); | |
145 | freeReplyObject(reply); | |
146 | ||
147 | return GEARMAND_QUEUE_ERROR; | |
148 | } | |
149 | ||
150 | freeReplyObject(reply); | |
151 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Auth success"); | |
124 | 152 | } |
125 | 153 | |
126 | 154 | gearmand_info("Initializing hiredis module"); |
118 | 118 | |
119 | 119 | data.vec_append_printf(".\n"); |
120 | 120 | } |
121 | else if (strcasecmp("prioritystatus", (char *)(packet->arg[0])) == 0) | |
122 | { | |
123 | uint32_t job_queued[GEARMAN_JOB_PRIORITY_MAX]; | |
124 | ||
125 | for (uint32_t function_key= 0; | |
126 | function_key < GEARMAND_DEFAULT_HASH_SIZE; | |
127 | function_key++) | |
128 | { | |
129 | for (gearman_server_function_st *function= Server->function_hash[function_key]; | |
130 | function != NULL; | |
131 | function= function->next) | |
132 | { | |
133 | for (size_t priority = 0; priority < GEARMAN_JOB_PRIORITY_MAX; priority++) | |
134 | { | |
135 | job_queued[priority] = 0; | |
136 | for (gearman_server_job_st *server_job= function->job_list[priority]; | |
137 | server_job != NULL; | |
138 | server_job= server_job->next) | |
139 | { | |
140 | job_queued[priority]++; | |
141 | } | |
142 | } | |
143 | ||
144 | data.vec_append_printf("%.*s\t%u\t%u\t%u\t%u\n", | |
145 | int(function->function_name_size), function->function_name, | |
146 | job_queued[GEARMAN_JOB_PRIORITY_HIGH], | |
147 | job_queued[GEARMAN_JOB_PRIORITY_NORMAL], | |
148 | job_queued[GEARMAN_JOB_PRIORITY_LOW], | |
149 | function->worker_count); | |
150 | } | |
151 | } | |
152 | data.vec_append_printf(".\n"); | |
153 | } | |
121 | 154 | else if (strcasecmp("status", (char *)(packet->arg[0])) == 0) |
122 | 155 | { |
123 | 156 | for (uint32_t function_key= 0; |
134 | 167 | function->job_running, function->worker_count); |
135 | 168 | } |
136 | 169 | } |
137 | ||
138 | 170 | data.vec_append_printf(".\n"); |
139 | 171 | } |
140 | 172 | else if (packet->argc >= 3 |
327 | 359 | { |
328 | 360 | data.vec_printf("OK %d\n", (int)getpid()); |
329 | 361 | } |
330 | else if (strcasecmp("shutdown", (char *)(packet->arg[0])) == 0) | |
331 | { | |
332 | if (packet->argc == 1) | |
333 | { | |
334 | Server->shutdown= true; | |
335 | data.vec_printf(TEXT_SUCCESS); | |
336 | } | |
337 | else if (packet->argc == 2 && | |
338 | strcasecmp("graceful", (char *)(packet->arg[1])) == 0) | |
339 | { | |
340 | Server->shutdown_graceful= true; | |
341 | data.vec_printf(TEXT_SUCCESS); | |
342 | } | |
343 | else | |
344 | { | |
345 | // shutdown | |
346 | data.vec_printf(TEXT_ERROR_ARGS, (int)packet->arg_size[0], (char *)(packet->arg[0])); | |
347 | } | |
348 | } | |
349 | 362 | else if (strcasecmp("verbose", (char *)(packet->arg[0])) == 0) |
350 | 363 | { |
351 | 364 | data.vec_printf("OK %s\n", gearmand_verbose_name(Gearmand()->verbose)); |
94 | 94 | |
95 | 95 | %files |
96 | 96 | %defattr(-,root,root,-) |
97 | %doc AUTHORS COPYING NEWS README HACKING THANKS | |
97 | %doc AUTHORS COPYING NEWS README.md HACKING THANKS | |
98 | 98 | %{_bindir}/gearadmin |
99 | 99 | %{_bindir}/gearman |
100 | 100 | %{_libdir}/libgearman.la |
105 | 105 | |
106 | 106 | %files server |
107 | 107 | %defattr(-,root,root,-) |
108 | %doc AUTHORS COPYING NEWS README HACKING THANKS | |
108 | %doc AUTHORS COPYING NEWS README.md HACKING THANKS | |
109 | 109 | %{_mandir}/man8/gearmand.8.gz |
110 | 110 | %{_sbindir}/gearmand |
111 | 111 | /etc/rc.d/init.d/gearmand |
114 | 114 | |
115 | 115 | %files devel |
116 | 116 | %defattr(-,root,root,-) |
117 | %doc AUTHORS COPYING NEWS README HACKING THANKS | |
117 | %doc AUTHORS COPYING NEWS README.md HACKING THANKS | |
118 | 118 | %{_includedir}/libgearman/gearman.h |
119 | 119 | %{_includedir}/libgearman-1.0/actions.h |
120 | 120 | %{_includedir}/libgearman-1.0/aggregator.h |
193 | 193 | snprintf(buffer, sizeof(buffer), "--port=%d", int(context->port())); |
194 | 194 | const char *args[]= { buffer, "--shutdown", 0 }; |
195 | 195 | |
196 | ASSERT_EQ(EXIT_SUCCESS, exec_cmdline("bin/gearadmin", args, true)); | |
197 | ||
198 | Server *server= context->servers.pop_server(); | |
199 | ASSERT_TRUE(server); | |
200 | ||
201 | // We will now quiet down the false error about it not being able to restart | |
202 | server->out_of_ban_killed(true); | |
203 | ||
204 | while (server->ping()) | |
205 | { | |
206 | // Wait out the death of the server | |
207 | } | |
208 | ||
209 | // Since we killed the server above, we need to reset it | |
210 | delete server; | |
196 | ASSERT_EQ(EXIT_FAILURE, exec_cmdline("bin/gearadmin", args, true)); | |
211 | 197 | |
212 | 198 | return TEST_SUCCESS; |
213 | 199 | } |
271 | 257 | |
272 | 258 | ASSERT_EQ(EXIT_SUCCESS, exec_cmdline("bin/gearadmin", args, true)); |
273 | 259 | |
260 | return TEST_SUCCESS; | |
261 | } | |
262 | ||
263 | static test_return_t gearadmin_priority_status_TEST(void* object) | |
264 | { | |
265 | cli::Context *context= (cli::Context*)object; | |
266 | ||
267 | char buffer[1024]; | |
268 | snprintf(buffer, sizeof(buffer), "--port=%d", int(context->port())); | |
269 | const char *args[]= { buffer, "--priority-status", 0 }; | |
270 | ||
271 | ASSERT_EQ(EXIT_SUCCESS, exec_cmdline("bin/gearadmin", args, true)); | |
274 | 272 | return TEST_SUCCESS; |
275 | 273 | } |
276 | 274 | |
443 | 441 | {"--show-jobs", 0, gearadmin_show_jobs_TEST}, |
444 | 442 | {"--show-unique-jobs", 0, gearadmin_show_unique_jobs_TEST}, |
445 | 443 | {"--status", 0, gearadmin_status_TEST}, |
444 | {"--priority-status", 0, gearadmin_priority_status_TEST}, | |
446 | 445 | {"gearman_client_do_background(100) --status", 0, gearadmin_status_with_jobs_TEST}, |
447 | 446 | {"--getpid", 0, gearadmin_getpid_test}, |
448 | 447 | {"--workers", 0, gearadmin_workers_test}, |
452 | 451 | }; |
453 | 452 | |
454 | 453 | test_st gearadmin_shutdown_tests[] ={ |
455 | {"--shutdown", 0, gearadmin_shutdown_test}, // Must be run last since it shuts down the server | |
454 | {"--shutdown", 0, gearadmin_shutdown_test}, // shutdown test is a relict. It doesn't shut down the server anymore | |
456 | 455 | {0, 0, 0} |
457 | 456 | }; |
458 | 457 |