Module: ServerProcessAble::ClassMethods

Defined in:
lib/app/models/concerns/server_process_able.rb

Overview

Methods for the concrete class this concern is attached too, ways to find or create or just find the associated server.

Instance Method Summary collapse

Instance Method Details

#find_or_create_serverObject

Find a record for this server



35
36
37
# File 'lib/app/models/concerns/server_process_able.rb', line 35

def find_or_create_server
  find_or_create_by!(host_name: Socket.gethostname, pid: Process.pid)
end

#find_serverObject

Find a worker, return nil if not found



42
43
44
45
46
# File 'lib/app/models/concerns/server_process_able.rb', line 42

def find_server
  find_by(host_name: Socket.gethostname, pid: Process.pid)
rescue StandardError
  nil
end