def PlugMan.start_plugin(name)
plug = @registered_plugins[name]
depends_on(name).each do |rqdname|
rqd = @registered_plugins[rqdname]
if !rqd
@logger.error { "Invalid plugin dependency #{rqdname.inspect} for plugin #{name.inspect}" }
end
if rqd.state == :stopped || rqd.state == :error
start_plugin(rqdname)
end
end
if plug.state == :stopped || plug.state == :error
@logger.debug { "Starting plugin #{plug.name.inspect}" }
if plug.start
plug.state :started
changed
notify_observers(:started, plug)
else
plug.state :error
@logger.error { "Failed to start plugin #{name.inspect}" }
changed
notify_observers(:error, plug)
raise PluginError.new(:start_failed)
end
end
end