diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-11-04 13:56:01 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-11-04 13:56:01 -0500 |
commit | b5cc6373fbfe2db20bb14216242c2c56f9bfbafe (patch) | |
tree | a5b692aae8c35b3dae8bb06d8eea17d144559bf2 /server_main.cpp | |
parent | ec9690bbf82829d1ba3bd0fc18831a43fe6405fe (diff) | |
download | wizard-b5cc6373fbfe2db20bb14216242c2c56f9bfbafe.tar.gz wizard-b5cc6373fbfe2db20bb14216242c2c56f9bfbafe.tar.bz2 wizard-b5cc6373fbfe2db20bb14216242c2c56f9bfbafe.zip |
Clean up cache every day
Also add a slight delay when downloading images to prevent rate limiting from Scryfall.
Diffstat (limited to 'server_main.cpp')
-rw-r--r-- | server_main.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/server_main.cpp b/server_main.cpp index 8d2c4aa..34cb50c 100644 --- a/server_main.cpp +++ b/server_main.cpp | |||
@@ -36,7 +36,8 @@ class server { | |||
36 | socket_.listen(port_); | 36 | socket_.listen(port_); |
37 | socket_.start_accept(); | 37 | socket_.start_accept(); |
38 | 38 | ||
39 | asio::post(std::bind(&server::cleanup_thread, this)); | 39 | std::thread cleanup(std::bind(&server::cleanup_thread, this)); |
40 | cleanup.detach(); | ||
40 | 41 | ||
41 | std::cout << "Listening on port " << port_ << "..." << std::endl; | 42 | std::cout << "Listening on port " << port_ << "..." << std::endl; |
42 | 43 | ||
@@ -145,7 +146,9 @@ class server { | |||
145 | 146 | ||
146 | void cleanup_thread() { | 147 | void cleanup_thread() { |
147 | for (;;) { | 148 | for (;;) { |
148 | // sleep | 149 | std::this_thread::sleep_for(std::chrono::hours(24)); |
150 | |||
151 | images_.cleanup(); | ||
149 | } | 152 | } |
150 | } | 153 | } |
151 | 154 | ||