Class: Hammer::CronServer::Job

Inherits:
Struct
  • Object
show all
Defined in:
lib/hammer/cron_server.rb

Overview

One scheduled task. pid doubles as the running flag: nil when idle, :starting between due-check and spawn, then the child pid.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject

Returns the value of attribute command

Returns:

  • (Object)

    the current value of command



22
23
24
# File 'lib/hammer/cron_server.rb', line 22

def command
  @command
end

#durationObject

Returns the value of attribute duration

Returns:

  • (Object)

    the current value of duration



22
23
24
# File 'lib/hammer/cron_server.rb', line 22

def duration
  @duration
end

#exit_codeObject

Returns the value of attribute exit_code

Returns:

  • (Object)

    the current value of exit_code



22
23
24
# File 'lib/hammer/cron_server.rb', line 22

def exit_code
  @exit_code
end

#last_runObject

Returns the value of attribute last_run

Returns:

  • (Object)

    the current value of last_run



22
23
24
# File 'lib/hammer/cron_server.rb', line 22

def last_run
  @last_run
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



22
23
24
# File 'lib/hammer/cron_server.rb', line 22

def path
  @path
end

#pidObject

Returns the value of attribute pid

Returns:

  • (Object)

    the current value of pid



22
23
24
# File 'lib/hammer/cron_server.rb', line 22

def pid
  @pid
end

#scheduleObject

Returns the value of attribute schedule

Returns:

  • (Object)

    the current value of schedule



22
23
24
# File 'lib/hammer/cron_server.rb', line 22

def schedule
  @schedule
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



22
23
24
# File 'lib/hammer/cron_server.rb', line 22

def status
  @status
end

Instance Method Details

#file_slugObject

Log-safe file name: 'db:backup' -> 'db-backup'.



29
30
31
# File 'lib/hammer/cron_server.rb', line 29

def file_slug
  path.tr(':', '-').gsub(/[^\w.-]/, '-')
end

#running?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/hammer/cron_server.rb', line 24

def running?
  !pid.nil?
end