Codebase list gearmand / be1c5fd
New upstream version 1.1.15 Alexandre Mestiashvili 7 years ago
14 changed file(s) with 233 addition(s) and 168 deletion(s). Raw diff Collapse all Expand all
1111 packages:
1212 - gcc-4.9
1313 - g++-4.9
14 artifacts: true
1415 env: COMPILER=g++-4.9
1516 - compiler: gcc
1617 addons:
2021 packages:
2122 - gcc-5
2223 - g++-5
24 artifacts: true
2325 env: COMPILER=g++-5
2426
2527 before_install:
556556 Arguments:
557557 - None.
558558
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
559579 maxqueue
560580
561581 This sets the maximum queue size for a function. If no size is
570590 - Optional maximum queue size (to apply one maximum at all priorities), or
571591 three optional maximum queue sizes (to enforce for high-, normal-, and
572592 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.
582593
583594 version
584595
+0
-90
README less more
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.
00 gearmand
11 ========
22
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)
44
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/)
66
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.
142142 ("show-jobs", "Show all jobs on the server.")
143143 ("getpid", "Get Process ID for the server.")
144144 ("status", "Status for the server.")
145 ("priority-status", "Queued jobs status by priority.")
145146 ("workers", "Workers for the server.")
146 ("shutdown", "Shutdown server.")
147147 ("ssl,S", "Enable SSL connections.")
148148 ;
149149
183183 vm.count("show-jobs") == 0 and
184184 vm.count("getpid") == 0 and
185185 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)
188188 {
189189 std::cout << "No option execution operation given." << std::endl << std::endl;
190190 std::cout << desc << std::endl;
191191 return EXIT_FAILURE;
192192 }
193193
194 if (vm.count("shutdown"))
195 {
196 instance.push(new util::Operation(util_literal_param("shutdown\r\n")));
197 }
198194
199195 if (vm.count("status"))
200196 {
201197 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")));
202203 }
203204
204205 if (vm.count("workers"))
257258
258259 if (not instance.run())
259260 {
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;
266264 }
267265
268266 return EXIT_SUCCESS;
0 #!/bin/bash
0 #!/usr/bin/env bash
11 #
22 # Copyright (C) 2012-2013 Brian Aker
33 # All rights reserved.
311311 VENDOR='suse'
312312 ;;
313313 *)
314 die "An attempt was made to set an invalid VENDOR=$_vendor"
314 die "An attempt was made to set an invalid VENDOR=$vendor"
315315 ;;
316316 esac
317317
4545
4646 Workers for the server.
4747
48 .. option:: --shutdown
49
50 Shutdown server.
51
5248
5349 -----------
5450 DESCRIPTION
4141
4242 Return the process id of the server.
4343
44 .. describe:: shutdown
45
46 Tell the server to shutdown.
47
4844 .. describe:: verbose
4945
5046 Change the verbose level of the server.
598598 {
599599 Client* client= client_shell->impl();
600600
601 if (gearman_connection_create(client->universal, host, port) == false)
601 if (gearman_connection_create(client->universal, host, port) == NULL)
602602 {
603603 assert(client->error_code() != GEARMAN_SUCCESS);
604604 return client->error_code();
613613
614614 gearman_return_t Client::add_server(const char *host, const char* service_)
615615 {
616 if (gearman_connection_create(universal, host, service_) == false)
616 if (gearman_connection_create(universal, host, service_) == NULL)
617617 {
618618 assert(error_code() != GEARMAN_SUCCESS);
619619 return error_code();
9292
9393 std::string server;
9494 std::string service;
95 std::string password;
9596
9697 private:
9798 redisContext *_redis;
105106 {
106107 command_line_options().add_options()
107108 ("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");
109111 }
110112
111113 Hiredis::~Hiredis()
121123 GEARMAN_DEFAULT_LOG_PARAM,
122124 GEARMAND_QUEUE_ERROR,
123125 "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");
124152 }
125153
126154 gearmand_info("Initializing hiredis module");
118118
119119 data.vec_append_printf(".\n");
120120 }
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 }
121154 else if (strcasecmp("status", (char *)(packet->arg[0])) == 0)
122155 {
123156 for (uint32_t function_key= 0;
134167 function->job_running, function->worker_count);
135168 }
136169 }
137
138170 data.vec_append_printf(".\n");
139171 }
140172 else if (packet->argc >= 3
327359 {
328360 data.vec_printf("OK %d\n", (int)getpid());
329361 }
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 }
349362 else if (strcasecmp("verbose", (char *)(packet->arg[0])) == 0)
350363 {
351364 data.vec_printf("OK %s\n", gearmand_verbose_name(Gearmand()->verbose));
9494
9595 %files
9696 %defattr(-,root,root,-)
97 %doc AUTHORS COPYING NEWS README HACKING THANKS
97 %doc AUTHORS COPYING NEWS README.md HACKING THANKS
9898 %{_bindir}/gearadmin
9999 %{_bindir}/gearman
100100 %{_libdir}/libgearman.la
105105
106106 %files server
107107 %defattr(-,root,root,-)
108 %doc AUTHORS COPYING NEWS README HACKING THANKS
108 %doc AUTHORS COPYING NEWS README.md HACKING THANKS
109109 %{_mandir}/man8/gearmand.8.gz
110110 %{_sbindir}/gearmand
111111 /etc/rc.d/init.d/gearmand
114114
115115 %files devel
116116 %defattr(-,root,root,-)
117 %doc AUTHORS COPYING NEWS README HACKING THANKS
117 %doc AUTHORS COPYING NEWS README.md HACKING THANKS
118118 %{_includedir}/libgearman/gearman.h
119119 %{_includedir}/libgearman-1.0/actions.h
120120 %{_includedir}/libgearman-1.0/aggregator.h
193193 snprintf(buffer, sizeof(buffer), "--port=%d", int(context->port()));
194194 const char *args[]= { buffer, "--shutdown", 0 };
195195
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));
211197
212198 return TEST_SUCCESS;
213199 }
271257
272258 ASSERT_EQ(EXIT_SUCCESS, exec_cmdline("bin/gearadmin", args, true));
273259
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));
274272 return TEST_SUCCESS;
275273 }
276274
443441 {"--show-jobs", 0, gearadmin_show_jobs_TEST},
444442 {"--show-unique-jobs", 0, gearadmin_show_unique_jobs_TEST},
445443 {"--status", 0, gearadmin_status_TEST},
444 {"--priority-status", 0, gearadmin_priority_status_TEST},
446445 {"gearman_client_do_background(100) --status", 0, gearadmin_status_with_jobs_TEST},
447446 {"--getpid", 0, gearadmin_getpid_test},
448447 {"--workers", 0, gearadmin_workers_test},
452451 };
453452
454453 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
456455 {0, 0, 0}
457456 };
458457
7878 if (gearman_failed(ret= gearman_client_echo(&client, test_literal_param("child forked"))))
7979 {
8080 Error << gearman_client_error(&client);
81 exit(int(ret));
81 _exit(int(ret));
8282 }
83 exit(0);
83 _exit(0);
8484 }
8585
8686 default: