Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F886207
worker.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 8, 10:51 PM
Size
1 KB
Mime Type
text/x-ruby
Expires
Sun, Aug 10, 10:51 PM (1 d, 1 h)
Engine
blob
Format
Raw Data
Handle
229629
Attached To
rARCHIVING archiving
worker.rb
View Options
require
'singleton'
module
Bean
class
Worker
include
Singleton
TIMEOUT
=
5
attr_accessor
:job
def
self
.
work
instance
.
work
end
def
work
register_signals
watch
rescue
Beaneater
::
NotConnected
Base
.
beanstalk_reconnect!
end
def
stop
if
job
.
nil?
exit
else
@stop
=
true
end
end
def
stop?
# rubocop:disable Style/TrivialAccessors
@stop
end
private
def
register_signals
trap
(
'INT'
)
{
stop
}
trap
(
'TERM'
)
{
stop
}
end
def
watch
loop
do
procline
(
'watching'
)
break
if
stop?
process_job
end
rescue
Beaneater
::
TimedOutError
retry
end
def
process_job
self
.
job
=
Base
.
bean
.
reserve
(
TIMEOUT
)
log_job
job
.
delete
ensure
self
.
job
=
nil
end
def
log_job
procline
(
"working on jobid=
#{
job
.
id
}
#{
job
.
body
}
"
)
Rails
.
logger
.
warn
(
job_id
:
job
.
id
,
job_body
:
job
.
body
.
to_s
)
end
def
procline
(
line
)
$0
=
"bean-
#{
line
}
"
end
end
end
Event Timeline
Log In to Comment