/* This file is part of Bolixo. Bolixo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Bolixo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Bolixo. If not, see . */ /* Command line tool to control bo-websocket */ #include #include #include #include #include #include #include #include #include #include #include #include "bolixo.h" using namespace std; #include "proto/bo-websocket_control.protoch" int main (int argc, char *argv[]) { glocal int ret = -1; glocal const char *control = "/var/run/bo-websocket-control.sock"; glocal.ret = (argc,argv); setproginfo ("publishd-control",VERSION ,"Command line tool to control bo-websocket\n" "\n" "\tdebug 0/1\n" "\tdebugfile filename\n" "\tdisconnectworkers\n" "\thelp_connect host port message\n" "\tinstrument 0|1\n" "\tpause\n" "\tresume\n" "\tquit\n" "\tset_debug_header 0|1\n" "\tstatus\n" ); setarg ('p',"control","Unix socket to reach bo-websocket",glocal.control,false); glocal int ret = -1; CONNECT_INFO con; con.port = glocal.control; if (strcmp(argv[0],"status")==0 && argc==1){ (con); glocal.ret = internal_error ? -1 : 0; for (auto x:lines) printf ("%s\n",x); }else if (strcmp(argv[0],"quit")==0 && argc==1){ (con); glocal.ret = internal_error ? -1 : 0; }else if (strcmp(argv[0],"test")==0 && argc==1){ (con); glocal.ret = internal_error ? -1 : 0; if (!ok){ tlmp_error ("test failed\n"); }else{ printf ("test ok, %u workers tested, paused=%d\n",workers,paused); } }else if (strcmp(argv[0],"debug")==0 && argc==2){ (con,atoi(argv[1])); glocal.ret = internal_error ? -1 : 0; }else if (strcmp(argv[0],"debugfile")==0 && argc==2){ (con,argv[1]); glocal.ret = internal_error ? -1 : 0; }else if (strcmp(argv[0],"instrument")==0 && argc==2){ (con,atoi(argv[1])); }else if (strcmp(argv[0],"disconnectworkers")==0 && argc==1){ (con); }else if (strcmp(argv[0],"pause")==0 && argc==1){ (con); }else if (strcmp(argv[0],"resume")==0 && argc==1){ (con); }else if (strcmp(argv[0],"set_debug_header")==0 && argc==2){ (con,atoi(argv[1]) != 0); }else{ tlmp_error ("Invalid command: %s\n",argv[0]); usage(); } return glocal.ret; return glocal.ret; }