centoschef-infraejabberdchef-soloknife-solo

Start Ejabberd as a service


I'm trying to install ejabbered on my CentOs server and start it as a service. I'm able to install it fine but not able to start it as a service.

error

* service[ejabberd] action enable
    * service[ejabberd]: No custom command for enable specified and unable to locate the init.d script!
    ================================================================================
    Error executing action `enable` on resource 'service[ejabberd]'
    ================================================================================

    Chef::Exceptions::Service
    -------------------------
    service[ejabberd]: No custom command for enable specified and unable to locate the init.d script!

    Resource Declaration:
    ---------------------
    # In /root/chef-solo/cookbooks-3/exelon/recipes/jabber.rb

     24: service "ejabberd" do
     25:   action :enable
     26: end
     27: 

    Compiled Resource:
    ------------------
    # Declared in /root/chef-solo/cookbooks-3/exelon/recipes/jabber.rb:24:in `from_file'

    service("ejabberd") do
      action [:enable]
      supports {:restart=>nil, :reload=>nil, :status=>nil}
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      service_name "ejabberd"
      pattern "ejabberd"
      declared_type :service
      cookbook_name :exelon
      recipe_name "jabber"
    end

Recipe: sysctl::default

jabber recipe

remote_file '/tmp/ejabberd-16.02-0.x86_64.rpm' do
  source 'https://www.process-one.net/downloads/downloads-action.php?file=/ejabberd/16.02/ejabberd-16.02-0.x86_64.rpm'
  owner 'deploy'
  group 'deploy'
  mode '0755'
  action :create
end

rpm_package 'ejabberd' do
  action :install
  source '/tmp/ejabberd-16.02-0.x86_64.rpm'
end

service "ejabberd" do
  action :enable
end

I've also tried using the ejabberdctl command. But it says No such file or directory - ejabberdctl

execute 'start ejabberd' do
  command 'ejabberdctl start'
end

Solution

  • As the error says, the RPM you are installing doesn't include a service config/script. If you unpack the RPM you can see it is just the server binaries. You could use poise_service to generate the service config or find one on their wiki I would imagine. Also re: the second error, it is installing to /opt/ejabberd, which is not on your $PATH.