Skip to content

Commit

Permalink
add travisCI (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
raozhiming authored and stiartsly committed Nov 17, 2018
1 parent 9694464 commit 4aca76b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: c

matrix:
include:
- os: osx
env: BUILD_ENV=darwin_x64

- env: BUILD_ENV=linux_x64
sudo: true

script:
- cd $TRAVIS_BUILD_DIR && mkdir build && cd build && mkdir $BUILD_ENV && cd $BUILD_ENV
- cmake -DCMAKE_INSTALL_PREFIX=dist ../..
- make && make install
- cd dist/bin && ./elacrawler -c ../etc/carrier/crawler.conf -v 7 -l 20
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Carrier Crawler
===============

[![Build Status](https://travis-ci.org/elastos/Elastos.NET.Carrier.Crawler.svg)](https://travis-ci.org/elastos/Elastos.NET.Carrier.Crawler)

## Summary

elacrawler is a Elastos Carrier network crawler.
Expand Down
18 changes: 14 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static int interrupted = 0;
static uint32_t running_crawlers = 0;
static time_t last_stamp;
static uint32_t last_index = 0;
static uint32_t node_limit = UINT32_MAX;

typedef struct Crawler {
Tox *tox;
Expand Down Expand Up @@ -259,7 +260,6 @@ static void crawler_connection_status(Tox *tox, TOX_CONNECTION status, void *use
};

vlogI("Crawler[%u] - connection status: %s", cwl->index, status_name[status]);

}

/*
Expand Down Expand Up @@ -378,6 +378,7 @@ static int crawler_get_data_filename(Crawler *cwl, char *buf, size_t buf_len)
static int crawler_dump_nodes(Crawler *cwl)
{
int rc;
uint32_t i;
char data_file[PATH_MAX];
char temp_file[PATH_MAX];
FILE *fp;
Expand All @@ -401,7 +402,7 @@ static int crawler_dump_nodes(Crawler *cwl)
return -1;
}

for (uint32_t i = 0; i < cwl->num_nodes; ++i) {
for (i = 0; i < cwl->num_nodes; ++i) {
size_t len = sizeof(id_str);
base58_encode(cwl->nodes_list[i].public_key, CRYPTO_PUBLIC_KEY_SIZE, id_str, &len);
ip_ntoa(&cwl->nodes_list[i].ip_port.ip, ip_str, sizeof(ip_str));
Expand Down Expand Up @@ -435,6 +436,11 @@ static bool crawler_finished(Crawler *cwl)
return true;
}

if (cwl->num_nodes >= node_limit) {
interrupted = 2;
return true;
}

return false;
}

Expand Down Expand Up @@ -561,14 +567,18 @@ int main(int argc, char **argv)
sys_coredump_set(true);
#endif

while ((opt = getopt_long(argc, argv, "c:v:h?",
while ((opt = getopt_long(argc, argv, "c:v:l:h?",
options, &idx)) != -1) {
switch (opt) {
case 'c':
strncpy(config_file, optarg, sizeof(config_file));
config_file[sizeof(config_file)-1] = 0;
break;

case 'l':
node_limit = atoi(optarg);
break;

case 'v':
log_level = atoi(optarg);
break;
Expand Down Expand Up @@ -636,5 +646,5 @@ int main(int argc, char **argv)

deref(config);

return 0;
return (interrupted == 2) ? 0 : 1;
}

0 comments on commit 4aca76b

Please sign in to comment.