ruby - why isn't gearmand processing workers? -


i on mac osx (yosemite)

installed using homebrew.

➜  ~  brew list gearmand /usr/local/cellar/gearman/1.1.12/bin/gearadmin /usr/local/cellar/gearman/1.1.12/bin/gearman /usr/local/cellar/gearman/1.1.12/homebrew.mxcl.gearman.plist /usr/local/cellar/gearman/1.1.12/include/libgearman/gearman.h /usr/local/cellar/gearman/1.1.12/include/libgearman-1.0/ (39 files) /usr/local/cellar/gearman/1.1.12/lib/libgearman.8.dylib /usr/local/cellar/gearman/1.1.12/lib/pkgconfig/gearmand.pc /usr/local/cellar/gearman/1.1.12/lib/ (2 other files) /usr/local/cellar/gearman/1.1.12/sbin/gearmand /usr/local/cellar/gearman/1.1.12/share/man/ (156 files) 

added /usr/local/sbin path (.bash-path) gearmand on path.

➜  ~  echo $path /users/davidvezzani/.rvm/gems/ruby-1.9.3-p551/bin:/users/davidvezzani/.rvm/gems/ruby-1.9.3-p551@global/bin:/users/davidvezzani/.rvm/rubies/ruby-1.9.3-p551/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/x11/bin:/usr/local/git/bin:/users/davidvezzani/.rvm/bin:/users/davidvezzani/bin 

checking if on path. , is.

➜  ~  gearmand /usr/local/sbin/gearmand 

trying start gearmand. expecting see log statements indicating server has started , it's waiting jobs process. there's nothing.

➜  ~  gearmand --verbose debug 

is running?!

501 17847 17693   0 11:24am ttys017    0:00.01 gearmand --verbose debug 

yes. have no idea doing. let's run 1 of examples gearman-ruby.

rvm use 2.2.0 gem install gearman-ruby mvim do_reverse.rb 

provide following content

#  reverse_do.rb require 'rubygems' require 'gearman'  # add our servers  servers = ['127.0.0.1:4730']  # initialize new client  client = gearman::client.new(servers)  puts "sending job..."; task = gearman::task.new('reverse', 'hello world!', {}) result = client.do_task task  puts "result: " + result 

run example client.

➜  work3  ruby reverse_do.rb d, [2015-07-21t14:00:40.717160 #21521] debug -- : performing health check 127.0.0.1:4730 (connected: false) d, [2015-07-21t14:00:40.717248 #21521] debug -- : attempt #0 connect 127.0.0.1:4730 d, [2015-07-21t14:00:40.718060 #21521] debug -- : health check response 127.0.0.1:4730 (connected: true) [:echo_res, "ping"] sending job... d, [2015-07-21t14:00:40.719181 #21521] debug -- : available job servers: [#<gearman::connection:0x007f960e049b78 @hostname="127.0.0.1", @port=4730, @real_socket=#<tcpsocket:fd 7>>] d, [2015-07-21t14:00:40.719215 #21521] debug -- : using 127.0.0.1:4730 (connected: true) submit job d, [2015-07-21t14:00:40.719473 #21521] debug -- : got job_created 127.0.0.1:4730 (connected: true) 

the client seems run, should see "result" @ point, not seeing that. missing?

from gearman documentation:

this document assumes high-level understanding of role of job server, clients, , workers.

three players in gearman architecture

since there 3 players involved here, when running example, @ least 1 gearman job server (this example shows running 2),

(execute terminal:)

gearmand --verbose debug -p 4730 gearmand --verbose debug -p 4731 

... start workers,

#  worker.rb require 'rubygems' require 'logger' require 'gearman'  servers = ['localhost:4730', 'localhost:4731']  w = gearman::worker.new(servers) logger = logger.new(stdout)  # add handler "sleep" function takes single argument, # number of seconds sleep before reporting success. w.add_ability("sleep") |data,job|  seconds = 10  logger.info "sleeping #{seconds} seconds"  (1..seconds.to_i).each |i|    sleep 1    # report our progress job server every second.    job.report_status(i, seconds)  end  # report success.  true end  w.add_ability("blah") |data,job|  logger.info "blah, blah, blah..."  # report our progress job server every second.  job.report_status(1, 1)  # report success.  true end  loop { w.work } 

(execute terminal:)

ruby worker.rb 

... , have client push job on stack.

#  reverse_do.rb require 'gearman'  servers = ['localhost:4730', 'localhost:4731']  client = gearman::client.new(servers) taskset = gearman::taskset.new(client)  task = gearman::task.new('sleep', 20) task.on_complete {|d| puts "finished client: #{d}" }  task2 = gearman::task.new('blah') task2.on_complete {|d| puts "finished client blah: #{d}" }  taskset.add_task(task) taskset.add_task(task2) taskset.wait(100) 

(execute terminal:)

ruby reverse_do.rb 

server results.

even through have turned on verbosity debug, i'm seeing no logging in terminal.

worker results.

➜  work3  ruby worker.rb d, [2015-07-21t15:04:34.868178 #22866] debug -- : performing health check localhost:4730 (connected: false) d, [2015-07-21t15:04:34.868258 #22866] debug -- : attempt #0 connect localhost:4730 d, [2015-07-21t15:04:34.869435 #22866] debug -- : health check response localhost:4730 (connected: true) [:echo_res, "ping"] d, [2015-07-21t15:04:34.869471 #22866] debug -- : performing health check localhost:4731 (connected: false) d, [2015-07-21t15:04:34.869493 #22866] debug -- : attempt #0 connect localhost:4731 d, [2015-07-21t15:04:34.869962 #22866] debug -- : health check response localhost:4731 (connected: true) [:echo_res, "ping"] d, [2015-07-21t15:04:34.870030 #22866] debug -- : announced ability sleep d, [2015-07-21t15:04:34.870107 #22866] debug -- : announced ability sleep d, [2015-07-21t15:04:34.870160 #22866] debug -- : announced ability blah d, [2015-07-21t15:04:34.870193 #22866] debug -- : announced ability blah d, [2015-07-21t15:04:34.870238 #22866] debug -- : sending grab_job localhost:4730 (connected: true) i, [2015-07-21t15:04:34.870417 #22866]  info -- : got no_job localhost:4730 (connected: true) d, [2015-07-21t15:04:34.870444 #22866] debug -- : sending grab_job localhost:4731 (connected: true) i, [2015-07-21t15:04:34.870620 #22866]  info -- : got no_job localhost:4731 (connected: true) i, [2015-07-21t15:04:34.870657 #22866]  info -- : sending pre_sleep , going sleep 30 second(s) d, [2015-07-21t15:04:34.870764 #22866] debug -- : polling on 2 available server(s) 30 second timeout d, [2015-07-21t15:04:53.263702 #22866] debug -- : received noop while sleeping... waking up! d, [2015-07-21t15:04:53.263801 #22866] debug -- : sending grab_job localhost:4730 (connected: true) i, [2015-07-21t15:04:53.264074 #22866]  info -- : got no_job localhost:4730 (connected: true) d, [2015-07-21t15:04:53.264101 #22866] debug -- : sending grab_job localhost:4731 (connected: true) i, [2015-07-21t15:04:53.264367 #22866]  info -- : got job_assign handle h:davids-imac.local:6 , 0 byte(s) localhost:4731 (connected: true) i, [2015-07-21t15:04:53.264399 #22866]  info -- : blah, blah, blah... d, [2015-07-21t15:04:53.264443 #22866] debug -- : sending work_complete h:davids-imac.local:6 4 byte(s) localhost:4731 (connected: true) d, [2015-07-21t15:04:53.264491 #22866] debug -- : sending grab_job localhost:4731 (connected: true) i, [2015-07-21t15:04:53.264710 #22866]  info -- : got no_job localhost:4731 (connected: true) i, [2015-07-21t15:04:53.264735 #22866]  info -- : sending pre_sleep , going sleep 30 second(s) d, [2015-07-21t15:04:53.264795 #22866] debug -- : polling on 2 available server(s) 30 second timeout d, [2015-07-21t15:04:53.265126 #22866] debug -- : received noop while sleeping... waking up! d, [2015-07-21t15:05:03.269974 #22866] debug -- : sending grab_job localhost:4730 (connected: true) i, [2015-07-21t15:05:03.270372 #22866]  info -- : got job_assign handle h:davids-imac.local:4 , 2 byte(s) localhost:4730 (connected: true) i, [2015-07-21t15:05:03.270405 #22866]  info -- : sleeping 10 seconds d, [2015-07-21t15:05:13.301296 #22866] debug -- : sending work_complete h:davids-imac.local:4 4 byte(s) localhost:4730 (connected: true) d, [2015-07-21t15:05:13.301415 #22866] debug -- : sending grab_job localhost:4730 (connected: true) i, [2015-07-21t15:05:13.301655 #22866]  info -- : got no_job localhost:4730 (connected: true) d, [2015-07-21t15:05:13.301696 #22866] debug -- : sending grab_job localhost:4731 (connected: true) i, [2015-07-21t15:05:13.301920 #22866]  info -- : got no_job localhost:4731 (connected: true) i, [2015-07-21t15:05:13.301951 #22866]  info -- : sending pre_sleep , going sleep 30 second(s) d, [2015-07-21t15:05:13.302023 #22866] debug -- : polling on 2 available server(s) 30 second timeout 

client results.

➜  work3  ruby reverse_do.rb d, [2015-07-21t14:55:09.896887 #22800] debug -- : performing health check localhost:4730 (connected: false) d, [2015-07-21t14:55:09.896973 #22800] debug -- : attempt #0 connect localhost:4730 d, [2015-07-21t14:55:09.898392 #22800] debug -- : health check response localhost:4730 (connected: true) [:echo_res, "ping"] d, [2015-07-21t14:55:09.898428 #22800] debug -- : performing health check localhost:4731 (connected: false) d, [2015-07-21t14:55:09.898451 #22800] debug -- : attempt #0 connect localhost:4731 d, [2015-07-21t14:55:09.898963 #22800] debug -- : health check response localhost:4731 (connected: true) [:echo_res, "ping"] d, [2015-07-21t14:55:09.899153 #22800] debug -- : available job servers: [#<gearman::connection:0x007fb6a309fd88 @hostname="localhost", @port=4730, @real_socket=#<tcpsocket:fd 9>>, #<gearman::connection:0x007fb6a309e258 @hostname="localhost", @port=4731, @real_socket=#<tcpsocket:fd 10>>] d, [2015-07-21t14:55:09.899182 #22800] debug -- : using localhost:4731 (connected: true) submit job d, [2015-07-21t14:55:09.899464 #22800] debug -- : got job_created localhost:4731 (connected: true) d, [2015-07-21t14:55:19.903692 #22800] debug -- : received work_status h:davids-imac.local:5: 1 / 1 d, [2015-07-21t14:55:19.903789 #22800] debug -- : received work_complete h:davids-imac.local:5 finished client blah: true d, [2015-07-21t14:55:19.903933 #22800] debug -- : available job servers: [#<gearman::connection:0x007fb6a309fd88 @hostname="localhost", @port=4730, @real_socket=#<tcpsocket:fd 9>>, #<gearman::connection:0x007fb6a309e258 @hostname="localhost", @port=4731, @real_socket=#<tcpsocket:fd 10>>] d, [2015-07-21t14:55:19.903993 #22800] debug -- : using localhost:4730 (connected: true) submit job d, [2015-07-21t14:55:19.904225 #22800] debug -- : got job_created localhost:4730 (connected: true) d, [2015-07-21t14:55:30.908445 #22800] debug -- : received work_status h:davids-imac.local:3: 1 / 10 d, [2015-07-21t14:55:31.911152 #22800] debug -- : received work_status h:davids-imac.local:3: 2 / 10 d, [2015-07-21t14:55:32.914036 #22800] debug -- : received work_status h:davids-imac.local:3: 3 / 10 d, [2015-07-21t14:55:33.916782 #22800] debug -- : received work_status h:davids-imac.local:3: 4 / 10 d, [2015-07-21t14:55:34.919513 #22800] debug -- : received work_status h:davids-imac.local:3: 5 / 10 d, [2015-07-21t14:55:35.922062 #22800] debug -- : received work_status h:davids-imac.local:3: 6 / 10 d, [2015-07-21t14:55:36.926507 #22800] debug -- : received work_status h:davids-imac.local:3: 7 / 10 d, [2015-07-21t14:55:37.930245 #22800] debug -- : received work_status h:davids-imac.local:3: 8 / 10 d, [2015-07-21t14:55:38.930387 #22800] debug -- : received work_status h:davids-imac.local:3: 9 / 10 d, [2015-07-21t14:55:39.933860 #22800] debug -- : received work_status h:davids-imac.local:3: 10 / 10 d, [2015-07-21t14:55:39.933983 #22800] debug -- : received work_complete h:davids-imac.local:3 finished client: true 

understanding high-level concepts important understood order scripts should executed after gearmand servers started working example can executed.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -