Class: DockerSwarm::Service

Inherits:
Base
  • Object
show all
Includes:
Concerns::Creatable, Concerns::Deletable, Concerns::Loggable, Concerns::Updatable
Defined in:
lib/docker_swarm/models/service.rb

Overview

Represents a Docker Swarm Service

Instance Method Summary collapse

Methods included from Concerns::Loggable

#logs

Methods included from Concerns::Deletable

#destroy

Methods included from Concerns::Updatable

#update

Methods included from Concerns::Creatable

#save

Methods inherited from Base

all, #as_json, #assign_attributes, #attributes, defined_attributes, find, #id, #initialize, #method_missing, #payload_for_docker, #persisted?, #reload, resource_name, #respond_to_missing?, root_key, routes, #serializable_hash, where

Methods included from Concerns::Inspectable

#inspect

Constructor Details

This class inherits a constructor from DockerSwarm::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class DockerSwarm::Base

Instance Method Details

#restartBoolean

Restarts the service by incrementing ForceUpdate, which causes Docker to recreate all tasks.

Returns:

  • (Boolean)

    true if the restart was triggered successfully



16
17
18
19
# File 'lib/docker_swarm/models/service.rb', line 16

def restart
  current = self.Spec&.dig("TaskTemplate", "ForceUpdate").to_i
  update(Spec: { TaskTemplate: { ForceUpdate: current + 1 } })
end