diff --git a/priv/dhtcrawler.config b/priv/dhtcrawler.config deleted file mode 100644 index bce6f7e..0000000 --- a/priv/dhtcrawler.config +++ /dev/null @@ -1,6 +0,0 @@ -[{start_port,6776}, - {node_count,50}, - {loglevel,3}, - {dbconn, 5}, - {dbhost,"localhost"}, - {dbport,27017}]. diff --git a/src/db_store_mongo.erl b/src/db_store_mongo.erl index c1c50de..a3fc7b3 100644 --- a/src/db_store_mongo.erl +++ b/src/db_store_mongo.erl @@ -115,8 +115,8 @@ inc_announce(Conn, Hash) when is_binary(Hash) -> % damn, mongodb-erlang doesnot support update a field for an object, % `findAndModify` works but it will change `announce' datatype to double Cmd = {findAndModify, ?COLLNAME, query, {'_id', Hash}, - update, {'$inc', {announce, 1}}, - new, true}, + update, {'$inc', {announce, 1}}, fields, {}, + new, false}, Ret = mongo_do(Conn, fun() -> mongo:command(Cmd) end), @@ -277,7 +277,7 @@ test_find_top() -> end). test_announce() -> - Hash = "F79ED3E2BF29A5C4358202E88C9983AB479D7722", + Hash = "6605993570A4A74C89FD02355333F3A86BEE6C1F", test_content(fun(Conn) -> inc_announce(Conn, Hash) end). diff --git a/src/hash_reader/db_hash_reader.erl b/src/hash_reader/hash_reader.erl similarity index 99% rename from src/hash_reader/db_hash_reader.erl rename to src/hash_reader/hash_reader.erl index 29ad020..c3b80c1 100644 --- a/src/hash_reader/db_hash_reader.erl +++ b/src/hash_reader/hash_reader.erl @@ -1,9 +1,9 @@ %% -%% db_hash_reader.erl +%% hash_reader.erl %% Kevin Lynx %% 06.28.2013 %% --module(db_hash_reader). +-module(hash_reader). -compile(export_all). -include("vlog.hrl"). -behaviour(gen_server). diff --git a/src/hash_reader/db_hash_reader_sup.erl b/src/hash_reader/hash_reader_sup.erl similarity index 86% rename from src/hash_reader/db_hash_reader_sup.erl rename to src/hash_reader/hash_reader_sup.erl index 041a30a..e95d32f 100644 --- a/src/hash_reader/db_hash_reader_sup.erl +++ b/src/hash_reader/hash_reader_sup.erl @@ -1,9 +1,9 @@ %% -%% db_hash_reader_sup.erl +%% hash_reader_sup.erl %% Kevin Lynx %% 06.29.2013 %% --module(db_hash_reader_sup). +-module(hash_reader_sup). -behaviour(supervisor). -export([init/1]). -export([start_link/3, @@ -34,7 +34,7 @@ start_standalone(IP, Port, Size) -> tor_download:start_global(), config:start_link("hash_reader.config", fun() -> config_default() end), % NOTE: - Stats = {db_hash_reader_stats, {hash_reader_stats, start_link, [Size]}, permanent, 2000, worker, [hash_reader_stats]}, + Stats = {hash_reader_stats, {hash_reader_stats, start_link, [Size]}, permanent, 2000, worker, [hash_reader_stats]}, DownloadStats = {tor_download_stats, {tor_download_stats, start_link, []}, permanent, 2000, worker, [tor_download_stats]}, Log = {vlog, {vlog, start_link, ["log/hash_reader.log", 3]}, permanent, 2000, worker, [vlog]}, start_link(IP, Port, Size, [DownloadStats, Stats, Log]). @@ -59,11 +59,11 @@ init([PoolName, Size, OtherProcess]) -> {ok, {Spec, Children}}. create_child(PoolName, Index) -> - {child_id(Index), {db_hash_reader, start_link, [PoolName]}, + {child_id(Index), {hash_reader, start_link, [PoolName]}, permanent, 1000, worker, dynamic}. child_id(Index) -> - list_to_atom(lists:flatten(io_lib:format("db_hash_reader_~p", [Index]))). + list_to_atom(lists:flatten(io_lib:format("hash_reader_~p", [Index]))). config_default() -> [{save_torrent, true}, diff --git a/tools/README.md b/tools/README.md index 7eb4b98..3808f9d 100644 --- a/tools/README.md +++ b/tools/README.md @@ -26,6 +26,10 @@ You can also compile the source code and run it manually. The source code is in Also you can check more technique information at my blog site (Chinese) [codemacro.com](http://codemacro.com) +## Source code + +dhtcrawler is totally open source, and can be used in any purpose, but you should keep my name on, copyright by me please. You can checkout dhtcrawler2 source code in this git repo **src** branch. + ## Config Most config value is in `priv/dhtcrawler.config`, when you first run dhtcrawler, this file will be generated automatically. And the other config values are passed by arguments to erlang functions. In most case you don't need to change these config values, except these network addresses. diff --git a/tools/win_start_hash.bat b/tools/win_start_hash.bat index 11b8d72..99ee4ce 100644 --- a/tools/win_start_hash.bat +++ b/tools/win_start_hash.bat @@ -1 +1 @@ -erl -pa ebin -noshell -run db_hash_reader_sup start_standalone localhost 27017 10 +erl -pa ebin -noshell -run hash_reader_sup start_standalone localhost 27017 10