diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-10-10 11:26:05 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-10-10 11:26:05 +0200 |
commit | c5351f58bcf494a56ecfd17fe5e68eb3b17dac7d (patch) | |
tree | bca845c55a2a7f407a856950a6293f0759d2e391 /src/crawl/crawl.cpp | |
parent | 5382e843f651f834c1df31bd494ed0638be07960 (diff) | |
download | crawler-c5351f58bcf494a56ecfd17fe5e68eb3b17dac7d.tar.gz crawler-c5351f58bcf494a56ecfd17fe5e68eb3b17dac7d.tar.bz2 |
added execution function to LuaVm
reorganized main lua.conf and calling several functions
Diffstat (limited to 'src/crawl/crawl.cpp')
-rwxr-xr-x | src/crawl/crawl.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/crawl/crawl.cpp b/src/crawl/crawl.cpp index 3a8fdff..e26de0a 100755 --- a/src/crawl/crawl.cpp +++ b/src/crawl/crawl.cpp @@ -71,8 +71,11 @@ int main( int /* argc */, char *argv[] ) // Logger::instance( ).openConsoleLog( logINFO ); Logger::instance( ).openConsoleLog( logDEBUG ); + // load configuration (Lua) and execute main (to + // get basic configuration in form of global + // variables) luaVm.loadSource( argv[1] ); - //luaVm.executeMain( ); + luaVm.executeMain( ); #ifndef _WIN32 struct sigaction sa; @@ -86,6 +89,7 @@ int main( int /* argc */, char *argv[] ) SetConsoleCtrlHandler( termHandler, TRUE ); #endif + // go through all type of modules and load them with the proper loader LOG( logNOTICE ) << "Loading modules"; vector<string> normalizerModules; @@ -98,6 +102,22 @@ int main( int /* argc */, char *argv[] ) #endif ModuleLoader<URLNormalizer> urlNormalizers( normalizerModules, CLOSE_DEFERRED, (void *)&luaVm ); +#ifdef WITH_LUA + // TODO: should be in the laoding function of libcrawl + tolua_URL_open( luaVm.handle( ) ); +#endif + + // initialize crawler function + luaVm.executeFunction( "init" ); + + // perform a crawl step + luaVm.executeFunction( "crawl" ); + + // cleaning up + luaVm.executeFunction( "destroy" ); + + return 0; + vector<string> filterModules; #ifndef _WIN32 filterModules.push_back( "./modules/urlfilter/protocol/mod_urlfilter_protocol.so" ); @@ -287,15 +307,6 @@ int main( int /* argc */, char *argv[] ) LOG( logNOTICE ) << "Crawler stopped.. normal shutdown.."; -#ifdef WITH_LUA - // TODO: should be in the laoding function of libcrawl - tolua_URL_open( luaVm.handle( ) ); -#endif - - luaVm.executeMain( ); - //luaVm.dumpState( ); - - return 0; } catch( exception &e ) { LOG( logFATAL ) << "Crawler stopped: " << e.what( ); return 1; |