Skip to content

Commit e518b30

Browse files
committed
fix remove bot
1 parent 4ef3b7b commit e518b30

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/ligretto_bot_clj/core.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
(tap> "test")
4343

4444
(tap> @system))
45+
4546
(defn shutdown-hook []
4647
(.addShutdownHook (Runtime/getRuntime)
4748
(Thread. ^Runnable

src/ligretto_bot_clj/web/app.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
[db]
1212
(log/info "Clearing DB")
1313
(doseq [[game-id game] @db]
14-
(if (empty? game)
15-
(swap! db dissoc game-id)
16-
(doseq [bot (vals game)]
17-
(when (= @(:status bot) :shutdown)
18-
(log/info "Removing bot" (:bot-id bot) "from game" game-id)
19-
(swap! db dissoc game-id (keyword (:bot-id bot))))))))
14+
(doseq [bot (vals game)]
15+
(when (= @(:status bot) :shutdown)
16+
(log/info "Removing bot" (:bot-id bot) "from game" game-id)
17+
(swap! db dissoc game-id (keyword (:bot-id bot)))))
18+
(when (empty? game)
19+
(swap! db dissoc game-id))))
2020

2121
(defn run-clear-db-worker
2222
"Runs worker to clear stopped bots from DB

src/ligretto_bot_clj/web/services/bot.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
bot (get-in @db [game-id* bot-id*])]
9191
(when (not (nil? bot))
9292
(stop-bot bot)
93-
(swap! db update-in [game-id] dissoc bot-id*)
93+
(swap! db update-in [game-id*] dissoc bot-id*)
9494
(->bot bot)))))
9595

9696
(defn remove-game

0 commit comments

Comments
 (0)