int fastrouter_init() { if (ufr.sockets) { if (ufr.use_cache && !uwsgi.cache_max_items) { uwsgi_log("you need to create a uwsgi cache to use the fastrouter (add --cache <n>)\n"); exit(1); } if (!ufr.nevents) ufr.nevents = 64; if (ufr.code_string_code && ufr.code_string_function) { if (register_fat_gateway("uWSGI fastrouter", fastrouter_loop) == NULL) { uwsgi_log("unable to register the fastrouter gateway\n"); exit(1); } } else { if (register_gateway("uWSGI fastrouter", fastrouter_loop) == NULL) { uwsgi_log("unable to register the fastrouter gateway\n"); exit(1); } } } return 0; }
int uwsgi_corerouter_init(struct uwsgi_corerouter *ucr) { int i; if (ucr->has_sockets) { if (ucr->use_cache && !uwsgi.cache_max_items) { uwsgi_log("you need to create a uwsgi cache to use the %s (add --cache <n>)\n", ucr->name); exit(1); } if (!ucr->nevents) ucr->nevents = 64; ucr->has_backends = uwsgi_courerouter_has_has_backends(ucr); uwsgi_corerouter_setup_sockets(ucr); if (ucr->processes < 1) ucr->processes = 1; if (ucr->cheap) { uwsgi_log("starting %s in cheap mode\n", ucr->name); } for (i = 0; i < ucr->processes; i++) { if (register_gateway(ucr->name, uwsgi_corerouter_loop, ucr) == NULL) { uwsgi_log("unable to register the %s gateway\n", ucr->name); exit(1); } } } return 0; }
int zergpool_init() { if (!zergpool_socket_names) return 0; struct uwsgi_string_list *zpsn = zergpool_socket_names; while(zpsn) { char *colon = strchr(zpsn->value, ':'); if (!colon) { uwsgi_log("invalid zergpool syntax: %s\n", zpsn->value); exit(1); } *colon = 0; add_zergpool_socket(zpsn->value, colon+1); *colon = ':'; zpsn = zpsn->next; } if (register_gateway("uWSGI zergpool", zergpool_loop) == NULL) { uwsgi_log("unable to register the zergpool gateway\n"); exit(1); } return 0; }
int erlang_init() { char *host; struct sockaddr_in sin; socklen_t slen = sizeof(struct sockaddr_in); char *ip = NULL; char *nodename; struct in_addr addr; uerl.lock = uwsgi_lock_init("erlang"); if (uerl.name) { host = strchr(uerl.name, '@'); if (!host) { if (ei_connect_init(&uerl.cnode, uerl.name, uerl.cookie, 0) < 0) { uwsgi_log("unable to initialize erlang connection\n"); exit(1); } } else { nodename = uwsgi_concat2n(uerl.name, host-uerl.name, "",0); ip = uwsgi_resolve_ip(host+1); if (ip) { #ifdef UWSGI_DEBUG uwsgi_log("ip: %s\n", ip); #endif addr.s_addr = inet_addr(ip); if (ei_connect_xinit(&uerl.cnode, host+1, nodename, uerl.name, &addr, uerl.cookie, 0) < 0) { uwsgi_log("unable to initialize erlang connection\n"); exit(1); } } else { if (ei_connect_init(&uerl.cnode, nodename, uerl.cookie, 0) < 0) { uwsgi_log("unable to initialize erlang connection\n"); exit(1); } } free(nodename); } if (ip) { uerl.fd = bind_to_tcp(ip, uwsgi.listen_queue, NULL); } else { uerl.fd = bind_to_tcp("", uwsgi.listen_queue, NULL); } if (uerl.fd < 0) { exit(1); } if (getsockname(uerl.fd, (struct sockaddr *) &sin, &slen)) { uwsgi_error("getsockname()"); exit(1); } if (ei_publish(&uerl.cnode, ntohs(sin.sin_port)) < 0) { uwsgi_log( "*** unable to subscribe with EPMD ***\n"); exit(1); } uwsgi_log("Erlang C-Node %s registered on port %d\n", ei_thisnodename(&uerl.cnode), ntohs(sin.sin_port)); if (register_gateway("uWSGI erlang c-node", erlang_loop, NULL) == NULL) { uwsgi_log("unable to register the erlang gateway\n"); exit(1); } } return 0; }