After start my redis server on my console using:
redis-server
I execute the following ruby script like this:
script/user/generate_roster_kids.rb start
But It does not work, I get:
generate_roster_kids] Pid not found, process seems doesn't exist!
[generate_roster_kids] Process daemonized with pid 1110 with thread and Forever v.0.3.2
if I execute the same command again I get the following:
generate_roster_kids] Found pid 1110...
[generate_roster_kids] Waiting the daemon's death . DONE
[generate_roster_kids] Process daemonized with pid 1385 with thread and Forever v.0.3.2
But it does not work, What I'm doing wrong.
This is the content of the generate_roster_kids.rb file:
#!/usr/bin/ruby
require 'rubygems' unless defined?(Gem)
require 'forever'
require 'redis'
Forever.run do
REDIS = Redis.new()
#
# dir "foo" # Default: File.expand_path('../../', __FILE__)
# file "bar" # Default: __FILE__
log "bar.log" # Default: File.expand_path(dir, '/log/[file_name].log')
# pid "bar.pid" # Default: File.expand_path(dir, '/tmp/[file_name].pid')
every 2.seconds do
# REDIS.DEL :busy
# begin
# REDIS.SUNIONSTORE :busy, REDIS.keys('Busy:*')
# rescue
# REDIS.SUNIONSTORE :busy, nil
# end
REDIS.SUNIONSTORE :busy, REDIS.keys('Busy:*') rescue REDIS.SUNIONSTORE :busy, nil
REDIS.EXPIRE :busy, 3
# online = REDIS.SUNION :online, REDIS.keys('Online:*')
# diff = REDIS.SDIFF online, :busy
# REDIS.SDIFFSTORE :online, (REDIS.SUNION :online, REDIS.keys('Online:*')), :busy
# REDIS.DEL :online
# begin
# REDIS.SUNIONSTORE :online, REDIS.keys('Online:*')
# rescue
# REDIS.SUNIONSTORE :online, nil
# end
REDIS.SUNIONSTORE :online, REDIS.keys('Online:*') rescue REDIS.SUNIONSTORE :online, nil
REDIS.EXPIRE :online, 3
end
end
This code was made by the older developer, but he's not available anymore and I need to make this work on my localmachine.
Thanks in advance
UPDATE
I check my redis-cli MONITOR and everything "works great", but I have the following problem, when a user change his status to ONLINE, I saw this on the MONITOR:
1400661418.908947 [0 127.0.0.1:57453] "DEL" "Busy:537c63ea20db9040d2000332"
1400661418.909909 [0 127.0.0.1:57453] "SREM" "busy" "537c63ea20db9040d2000332"
1400661418.910687 [0 127.0.0.1:57453] "sadd" "Online:537c63ea20db9040d2000332" "537c63ea20db9040d2000332"
1400661418.911705 [0 127.0.0.1:57453] "expire" "Online:537c63ea20db9040d2000332" "2"
1400661419.436520 [0 127.0.0.1:62027] "keys" "Busy:*"
1400661419.437205 [0 127.0.0.1:62027] "SUNIONSTORE" "busy" ""
1400661419.437489 [0 127.0.0.1:62027] "EXPIRE" "busy" "3"
1400661419.437757 [0 127.0.0.1:62027] "keys" "Online:*"
1400661419.438070 [0 127.0.0.1:62027] "SUNIONSTORE" "online" "Online:537c63ea20db9040d2000332"
If the user change to BUSY, I saw this:
400661508.795043 [0 127.0.0.1:57453] "DEL" "Online:537c63ea20db9040d2000332"
1400661508.796853 [0 127.0.0.1:57453] "SREM" "online" "537c63ea20db9040d2000332"
1400661508.798088 [0 127.0.0.1:57453] "sadd" "Busy:537c63ea20db9040d2000332" "537c63ea20db9040d2000332"
1400661508.799496 [0 127.0.0.1:57453] "expire" "Busy:537c63ea20db9040d2000332" "2"
1400661509.157067 [0 127.0.0.1:62027] "keys" "Busy:*"
1400661509.157751 [0 127.0.0.1:62027] "SUNIONSTORE" "busy" "Busy:537c63ea20db9040d2000332"
But when I check on my redis data base using the redisdesktopmanager, I don't see any new record, but If I try to create the records manually using the redis-cli the records are create successfully, what might be the problem, here????