// get web from redis and calculate pagerank void pagerank_redis(redisContext **conts, float v_quadratic_error, web* w) { redisContext *c = conts[0]; redisReply *reply; long long t_start; long long t_end; unsigned int i; float q = 1; printf("Start PageRank from redis: \n"); printf("Damping factor: %f\n", g_damping_factor); printf("Quadratic error range: %f\n", v_quadratic_error); printf("----------------------------------\n"); reply = redisCommand(c, "GET next.uid"); if (reply->str == NULL) die("Cannot not find data in redis!"); unsigned long user_num = atol(reply->str) + 1; printf("user num: %ld\n", user_num); freeReplyObject(reply); t_start = ustime(); if (w->size == 0) { for (i = 0; i < g_n_sharded; ++i) { reply = redisCommand(conts[i], "DEL newly.edited.linkto"); freeReplyObject(reply); reply = redisCommand(conts[i], "DEL newly.edited.linkfrom"); freeReplyObject(reply); } web_init(w, user_num); gen_web_sharded_redis(conts, w, 0); } else { size_t origin_size = w->size; web_init_from_oldweb(w, user_num); printf("web expansion fin..."); update_web_sharded_redis(conts, w); printf("web update fin...\n"); //printf("origin dangpage size: %zd\n", w->dangling_pages->size); update_dangling_pages(w, origin_size); //printf("updated dangpage size: %zd\n", w->dangling_pages->size); } printf("dangling user size: %zd\n", w->dangling_pages->size); t_end = ustime(); printf("init: %lf seconds\n", getruntime(t_end, t_start)); t_start = ustime(); for (i = 1; q > v_quadratic_error; ++i) { q = calculate_pagerank_parallel(w); //printf("iteration %d deviate value: %f\n", i, q); //web_display_pagerank(w); } t_end = ustime(); printf("calculate: %lf seconds(%d iterations)\n", getruntime(t_end, t_start), i - 1); }
int main() { wire_stack_fault_detector_install(); wire_thread_init(&wire_thread_main); wire_fd_init(); wire_io_init(8); wire_log_init_stdout(); register_shutdown_handler(); disk_manager_init(); web_init(5001); wire_thread_run(); return 0; }
int main(int argc, char** argv) { int rc; const char* port = "80"; struct engine* eng; while ((rc = getopt(argc, argv, "hp:")) != -1) { switch (rc) { case 'p': port = optarg; break; case 'h': usage(0); break; default: usage(2); break; } } if (pal_init(&pal)) return -1; eng = engine_init(&pal); rc = web_init(eng, port); if (rc) { LOG(("Web server failed to start: (%d) %s\n", rc, strerror(rc))); return rc; } LOG(("Running engine\n")); web_run(); engine_run(); web_destroy(); engine_destroy(); pal_destroy(&pal); LOG(("Exited gracefully\n")); return 0; }
int main(int argc, char *argv[]) { struct netif *nif; int vdefd; char *conffile=NULL; char *nodename=NULL; int c; progname=argv[0]; while (1) { int option_index = 0; static struct option long_options[] = { {"daemon", 0, 0, 'd'}, {"mgmt", 1, 0, 'M'}, {"telnet", 0, 0, 't'}, {"web", 0, 0, 'w'}, {"help",0,0,'h'}, {"rcfile",1,0,'f'}, {"nodename",1,0,'n'}, {"pidfile", 1, 0, 'p'}, {0, 0, 0, 0} }; c = getopt_long_only (argc, argv, "hdwtM:f:n:", long_options, &option_index); if (c == -1) break; switch (c) { case 'M': mgmt=strdup(optarg); break; case 'f': conffile=strdup(optarg); break; case 'n': nodename=strdup(optarg); break; case 't': telnet=1; break; case 'w': web=1; break; case 'd': daemonize=1; break; case 'p': pidfile=strdup(optarg); break; case 'h': usage(argv[0]); //implies exit break; } } if (optind < argc && mgmt==NULL) mgmt=argv[optind]; if (mgmt==NULL) { printlog(LOG_ERR,"mgmt_socket not defined"); exit(-1); } if (telnet==0 && web==0) { printlog(LOG_ERR,"at least one service option (-t -w) must be specified"); exit(-1); } atexit(cleanup); setsighandlers(); /* saves current path in pidfile_path, because otherwise with daemonize() we * forget it */ if(getcwd(pidfile_path, _POSIX_PATH_MAX-1) == NULL) { printlog(LOG_ERR, "getcwd: %s", strerror(errno)); exit(1); } strcat(pidfile_path, "/"); /* call daemon before starting the stack otherwise the stack threads * does not get inherited by the forked process */ if (daemonize && special_daemon()) { printlog(LOG_ERR,"daemon: %s",strerror(errno)); exit(1); } lwipstack=lwip_stack_new(); lwip_stack_set(lwipstack); vdefd = openvdem(mgmt, argv[0], &nif, nodename); /* If rcfile is specified, try it and nothing else */ if (conffile && readconffile(conffile,nif) < 0) { printlog(LOG_ERR, "Error reading configuration file '%s': %s", conffile, strerror(errno)); exit(1); } /* Else try default ones */ else if (!conffile) { int rv; char *homedir = getenv("HOME"); if (homedir) { int len = strlen(homedir) + strlen(USERCONFFILE) + 1; conffile = malloc(len); snprintf(conffile, len, "%s%s", homedir, USERCONFFILE); if ((rv = readconffile(conffile, nif)) >= 0) free(conffile); } if (!homedir || rv < 0) rv = readconffile(conffile = ROOTCONFFILE, nif); if (rv < 0) { printlog(LOG_ERR, "Error reading configuration file '%s': %s", conffile, strerror(errno)); exit(1); } } /* once here, we're sure we're the true process which will continue as a * server: save PID file if needed */ if(pidfile) save_pidfile(); if (telnet) telnet_init(vdefd); if (web) web_init(vdefd); if (daemonize) { int fd; if ((fd=open("/dev/null",O_RDWR)) >= 0) { close(STDERR_FILENO); dup2(fd,STDERR_FILENO); close(fd); openlog(basename(argv[0]), LOG_PID, 0); logok=1; } printlog(LOG_INFO,"VDETELWEB started"); } while (1) { int i; int m=lwip_poll(pfd,npfd,-1); for (i=0;i<npfd && m>0;i++) { if (pfd[i].revents) { m--; fpfd[i](i,pfd[i].fd,vdefd); } } } }
/** @brief main() Initialize user task @return void */ MEMSPACE void setup(void) { int i; char time[20]; int ret; uint16_t *ptr; double ang; extern web_init(); int w,h; ip_msg[0] = 0; // CPU // 160MHZ REG_SET_BIT(0x3ff00014, BIT(0)); // 80MHZ // REG_CLR_BIT(0x3ff00014, BIT(0)); os_delay_us(200000L); // Power Up dalay - lets power supplies and devices settle // Configure the UART //uart_init(BIT_RATE_115200,BIT_RATE_115200); uart_init(BIT_RATE_74880,BIT_RATE_74880); os_delay_us(200000L); // Power Up dalay - lets power supplies and devices settle os_delay_us(200000L); // Power Up dalay - lets power supplies and devices settle printf("\n\n\n\n"); sep(); printf("System init...\n"); printf("ESP8266 multidevice project\n"); printf(" (c) 2014-2017 by Mike Gore\n"); printf(" GNU version 3\n"); printf("-> https://github.com/magore/esp8266_ili9341\n"); printf(" GIT last pushed: %s\n", GIT_VERSION); printf(" Last updated file: %s\n", LOCAL_MOD); sep(); PrintRam(); sep(); printf("HSPI init...\n"); hspi_init(1,0); printf("Timers init...\n"); init_timers(); // 1000HZ timer ms_init(); test_types(); // Functions manage user defined address pins chip_addr_init(); initialize_clock(300); #ifdef ADF4351 #ifdef ADF4351_CS chip_select_init(ADF4351_CS); #endif ADF4351_Init(); printf("ADF4351 init done\n"); #endif // Make sure all other GPIO pins are initialized BEFORE SD card #ifdef FATFS_SUPPORT sep(); // Functions manage chip selects #ifdef MMC_CS chip_select_init(MMC_CS); #endif printf("SD Card init...\n"); mmc_init(1); #endif #ifdef DISPLAY sep(); #ifdef ILI9341_CS chip_select_init(ILI9341_CS); #endif #ifdef XPT2046_CS XPT2046_spi_init(); #endif // Initialize TFT master = tft_init(); tft_calX = MatRead("/tft_calX"); tft_calY = MatRead("/tft_calY"); if(tft_calX.data == NULL || tft_calY.data == NULL) tft_is_calibrated = 0; else tft_is_calibrated = 1; printf("TFT calibration %s\n", tft_is_calibrated ? "YES" : "NO"); // rotateion = 1, debug = 1 setup_windows(1,1); #endif wdt_reset(); sep(); printf("Setup Tasks\n"); sep(); setup_networking(); #ifdef TELNET_SERIAL printf("Setup Network Serial Bridge\n"); bridge_task_init(23); #endif if ( espconn_tcp_set_max_con(MAX_CONNECTIONS+1) ) printf("espconn_tcp_set_max_con(%d) != (%d) - failed!\n", MAX_CONNECTIONS+1, espconn_tcp_get_max_con()); else printf("espconn_tcp_set_max_con(%d) = (%d) - success!\n", MAX_CONNECTIONS+1, espconn_tcp_get_max_con()); #ifdef NETWORK_TEST printf("Setup Network TFT Display Client\n"); servertest_setup(TCP_PORT); #endif #ifdef WEBSERVER printf("Setup Network WEB SERVER\n"); web_init(80); #endif sep(); PrintRam(); system_set_os_print(0); } //setup()