Closed prem-prakash closed 3 years ago
No, but you can define your custom task like this:
task :setup_all_services do
invoke 'systemd:example1:setup'
invoke 'systemd:example2:setup'
end
I am intending to automate in a way that all services that were registered could be set up at once, without having to list each one of the services. But unfortunately, I am no expert in capistrano, so I don't know how to do that.
without having to list each one of the services
Hmm, I prefer to write all service names explicitly, but you meen you don't want to write service names explicitly, like this?
task :setup_all_services do
some_method_returns_all_registered_services.each do |service_name|
invoke "systemd:#{service_name}:setup"
end
end
If you really want to do that, ObjectSpace.each_object returns registered services.
task :setup_all_services do
ObjectSpace.each_object(Capistrano::Systemd::MultiService::SystemService).map(&:app).each do |service_name|
invoke "systemd:#{service_name}:setup"
end
end
Yeah that's exactly what I needed. Thank you very much.
Is there an easy way to set up all registered services with a single command?