Files
        @ 8fd7f81b1946
    
        
              Branch filter: 
        
    Location: libtransport.git/backends/twitter/main.cpp - annotation
        
            
            8fd7f81b1946
            1.4 KiB
            text/x-c++hdr
        
        
    
    Check explicitly for MSVC to fix the compilation with clang
    | cb62e786889f 137727e70ef9 137727e70ef9 f9696d0db6f1 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 f9696d0db6f1 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 f9696d0db6f1 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 f9696d0db6f1 137727e70ef9 3720df9cbef9 3720df9cbef9 3720df9cbef9 3720df9cbef9 137727e70ef9 137727e70ef9 137727e70ef9 3720df9cbef9 137727e70ef9 cb62e786889f 3720df9cbef9 3f59eeef9537 08a5e487db0c 08a5e487db0c 110a366bfb86 e691d05c4786 e691d05c4786 3f59eeef9537 e691d05c4786 e691d05c4786 e691d05c4786 137727e70ef9 137727e70ef9 137727e70ef9 3720df9cbef9 137727e70ef9 137727e70ef9 137727e70ef9 137727e70ef9 | #include "TwitterPlugin.h"
DEFINE_LOGGER(logger, "Twitter Backend");
#ifndef _WIN32
static void spectrum_sigchld_handler(int sig)
{
	int status;
	pid_t pid;
	do {
		pid = waitpid(-1, &status, WNOHANG);
	} while (pid != 0 && pid != (pid_t)-1);
	if ((pid == (pid_t) - 1) && (errno != ECHILD)) {
		char errmsg[BUFSIZ];
		snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
		perror(errmsg);
	}
}
#endif
int main (int argc, char* argv[]) {
	std::string host;
	int port;
#ifndef _WIN32
	if (signal(SIGCHLD, spectrum_sigchld_handler) == SIG_ERR) {
		std::cout << "SIGCHLD handler can't be set\n";
		return -1;
	}
#endif
	std::string error;
	Config *cfg = Config::createFromArgs(argc, argv, error, host, port);
	if (cfg == NULL) {
		std::cerr << error;
		return 1;
	}
	Logging::initBackendLogging(cfg);
	StorageBackend *storagebackend;
	storagebackend = StorageBackend::createBackend(cfg, error);
	if (storagebackend == NULL) {
		LOG4CXX_ERROR(logger, "Error creating StorageBackend! " << error);
		LOG4CXX_ERROR(logger, "Twitter backend needs storage backend configured to work! " << error);
		return NetworkPlugin::StorageBackendNeeded;
	}
	else if (!storagebackend->connect()) {
		LOG4CXX_ERROR(logger, "Can't connect to database!")
		return -1;
	}
	Swift::SimpleEventLoop eventLoop;
	loop_ = &eventLoop;
	np = new TwitterPlugin(cfg, &eventLoop, storagebackend, host, port);
	loop_->run();
	return 0;
}
 |