Sha256: c6737b112754517bcfe880d2c06116a00d6d12b582106f1a020c2154764c1822

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

require 'itamae'

module Itamae
  module Resource
    class Service < Base
      define_attribute :action, default: :nothing
      define_attribute :name, type: String, default_name: true

      def start_action
        run_init_script("start")
      end

      def stop_action
        run_init_script("stop")
      end

      def restart_action
        run_init_script("restart")
      end

      def reload_action
        run_init_script("reload")
      end

      private
      def run_init_script(command)
        run_command("#{shell_escape(init_script_path)} #{command}")
      end

      def init_script_path
        "/etc/init.d/#{name}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itamae-1.0.0.beta3 lib/itamae/resource/service.rb