class PoiseService::ServiceProviders::SolarisService

Poise-service provider for Solaris. @since 1.0.0

Public Class Methods

provides_auto?(node, _) click to toggle source
# File lib/poise_service/solaris/provider.rb, line 25
def self.provides_auto?(node, _)
  node['platform_family'] == 'solaris2'
end

Public Instance Methods

pid() click to toggle source

Parse the PID from ‘svcs -p <name>` output. @return [Integer]

# File lib/poise_service/solaris/provider.rb, line 31
def pid
  service = shell_out!("svcs -p #{@new_resource.service_name}").stdout
  service.split(' ')[-1].to_i
end

Private Instance Methods

create_service() click to toggle source
# File lib/poise_service/solaris/provider.rb, line 42
def create_service
  Chef::Log.debug("Creating solaris service #{new_resource.service_name}")

  template manifest_file do
    source 'manifest.xml.erb'
    cookbook 'poise-service-solaris' # poise needs cookbook name for template
    verify 'svccfg validate %{file}'
    variables(
      name: new_resource.service_name,
      command: new_resource.command,
      user: new_resource.user,
      environment: new_resource.environment,
      directory: new_resource.directory
    )
  end

  execute 'load service manifest' do
    # we synchrously disable and enable instead of
    # calling restart to avoid timing problem
    command 'svcadm disable -s manifest-import && svcadm enable -s manifest-import'
    # svcs <service_name> returns 0 if service exists
    not_if "svcs #{new_resource.service_name}"
  end
end
destroy_service() click to toggle source
# File lib/poise_service/solaris/provider.rb, line 67
def destroy_service
  Chef::Log.debug("Destroying solaris service #{new_resource.service_name}")
  file manifest_file do
    action :delete
  end

  execute 'load service manifest' do
    # we synchrously disable and enable instead of
    # calling restart to avoid timing problem
    command 'svcadm disable -s manifest-import && svcadm enable -s manifest-import'
    # svcs <service_name> returns 0 if service exists
    only_if "svcs #{new_resource.service_name}"
  end
end
manifest_file() click to toggle source
# File lib/poise_service/solaris/provider.rb, line 38
def manifest_file
  "/lib/svc/manifest/site/#{new_resource.service_name}.xml"
end
service_provider() click to toggle source
Calls superclass method
# File lib/poise_service/solaris/provider.rb, line 82
def service_provider
  super.tap do |r|
    r.provider(Chef::Provider::Service::Solaris)
  end
end