mirror of
https://github.com/btdig/dhtcrawler2.git
synced 2025-02-23 21:59:04 +00:00
rename db_hash_reader to hash_reader, change inc_announce response field
This commit is contained in:
parent
b9130ec759
commit
46338b02c6
@ -1,6 +0,0 @@
|
||||
[{start_port,6776},
|
||||
{node_count,50},
|
||||
{loglevel,3},
|
||||
{dbconn, 5},
|
||||
{dbhost,"localhost"},
|
||||
{dbport,27017}].
|
@ -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).
|
||||
|
@ -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).
|
@ -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},
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user