28 lines
806 B
Ruby
28 lines
806 B
Ruby
class StartServerJob < ApplicationJob
|
|
queue_as :default
|
|
|
|
def perform(server_id)
|
|
server = Server.find(server_id)
|
|
log "Starting server: #{server.name}"
|
|
|
|
begin
|
|
log "Calling SystemdManager.start..."
|
|
L4dServer::SystemdManager.start(server)
|
|
log "SystemdManager.start completed successfully"
|
|
|
|
server.update(status: :starting)
|
|
log "Server status updated to starting"
|
|
|
|
Activity.log(server.user, "started", "Server", server.id, {})
|
|
log "Activity logged"
|
|
rescue StandardError => e
|
|
log "ERROR: Failed to start server: #{e.message}"
|
|
log "Backtrace: #{e.backtrace.first(3).join("\n")}"
|
|
|
|
server.update(status: :failed)
|
|
Activity.log(server.user, "start_failed", "Server", server.id, { error: e.message })
|
|
|
|
raise
|
|
end
|
|
end
|
|
end
|