Software /
code /
prosody
Comparison
tools/migration/prosody-migrator.lua @ 12167:03f551510b1e
migrator: Enhance logging
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 09 Jan 2022 16:35:43 +0100 |
parent | 12166:39483b4099b4 |
child | 12168:33e856c65033 |
comparison
equal
deleted
inserted
replaced
12166:39483b4099b4 | 12167:03f551510b1e |
---|---|
148 local sm = require "core.storagemanager"; | 148 local sm = require "core.storagemanager"; |
149 local um = require "core.usermanager"; | 149 local um = require "core.usermanager"; |
150 | 150 |
151 local function users(store, host) | 151 local function users(store, host) |
152 if store.users then | 152 if store.users then |
153 log("debug", "Using store user iterator") | |
153 return store:users(); | 154 return store:users(); |
154 else | 155 else |
156 log("debug", "Using usermanagre user iterator") | |
155 return um.users(host); | 157 return um.users(host); |
156 end | 158 end |
157 end | 159 end |
158 | 160 |
159 local function prepare_config(host, conf) | 161 local function prepare_config(host, conf) |
184 end; | 186 end; |
185 } | 187 } |
186 | 188 |
187 if options["keep-going"] then | 189 if options["keep-going"] then |
188 local xpcall = require "util.xpcall".xpcall; | 190 local xpcall = require "util.xpcall".xpcall; |
189 local function log_err(err) | |
190 log("error", "Error migrating data: %s", err); | |
191 log("debug", "%s", debug.traceback()); | |
192 end | |
193 for t, f in pairs(migrate_once) do | 191 for t, f in pairs(migrate_once) do |
194 migrate_once[t] = function (origin, destination, user) | 192 migrate_once[t] = function (origin, destination, user) |
193 local function log_err(err) | |
194 if user then | |
195 log("error", "Error migrating data for user %q: %s", user, err); | |
196 else | |
197 log("error", "Error migrating data for host: %s", err); | |
198 end | |
199 log("debug", "%s", debug.traceback(nil, 2)); | |
200 end | |
195 xpcall(f, log_err, origin, destination, user); | 201 xpcall(f, log_err, origin, destination, user); |
196 end | 202 end |
197 end | 203 end |
198 end | 204 end |
199 | 205 |
218 local migrate = assert(migrate_once[typ], "Unknown store type: "..typ); | 224 local migrate = assert(migrate_once[typ], "Unknown store type: "..typ); |
219 | 225 |
220 migrate(origin, destination, nil); -- host data | 226 migrate(origin, destination, nil); -- host data |
221 | 227 |
222 for user in users(origin, host) do | 228 for user in users(origin, host) do |
229 log("info", "Migrating user %s@%s store %s (%s)", user, host, store, typ); | |
223 migrate(origin, destination, user); | 230 migrate(origin, destination, user); |
224 end | 231 end |
225 end | 232 end |
226 end | 233 end |
227 end, watchers); | 234 end, watchers); |