From f09f6cfb6850eac8a75b776d0f474a9ecb57f4fa Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 9 Nov 2018 13:52:41 +0100 Subject: add logs --- shard/lib/manager.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shard/lib/manager.ex b/shard/lib/manager.ex index efa9189..ab73b68 100644 --- a/shard/lib/manager.ex +++ b/shard/lib/manager.ex @@ -99,12 +99,14 @@ defmodule Shard.Manager do [{^shard_id, manifest, {:cached, _}, _}] -> pid = case :ets.lookup(:shard_procs, {shard_id, nil}) do [] -> + Logger.info("Starting #{ShardURI.from_manifest manifest} for deletion") {:ok, pid} = apply(Shard.Manifest.module(manifest), :start_link, [manifest]) pid [{{^shard_id, nil}, pid}] -> :ets.delete(:shard_procs, {shard_id, nil}) pid end + Logger.info("Deleting #{ShardURI.from_manifest manifest}") GenServer.call(pid, :delete_shard) :dets.delete(@shard_db, shard_id) {:reply, :ok, state} @@ -196,11 +198,12 @@ defmodule Shard.Manager do currtime = System.os_time :seconds shards = :dets.select(@shard_db, [{ - {:'$1', :_, {:cached, :'$2'}, :_}, [{:<, :'$2', currtime}], [:'$1']} + {:'$1', :'$2', {:cached, :'$3'}, :_}, [{:<, :'$3', currtime}], [:'$1', :'$2']} ]) - for [id] <- shards do + for [id, manifest] <- shards do case :ets.lookup(:shard_procs, {id, nil}) do [{{^id, nil}, pid}] -> + Logger.info("Deleting expired #{ShardURI.from_manifest manifest}") GenServer.call(pid, :delete_shard) _ -> nil end @@ -238,6 +241,7 @@ defmodule Shard.Manager do case :ets.lookup(:shard_procs, {shard_id, nil}) do [] -> + Logger.info("Starting #{ShardURI.from_manifest manifest}") {:ok, pid} = apply(Shard.Manifest.module(manifest), :start_link, [manifest]) GenServer.cast(pid, :send_deps) :ets.insert(:shard_procs, {{shard_id, nil}, pid}) -- cgit v1.2.3