y_socket: add help and kill cmd, update usage_cmdl
This commit is contained in:
@@ -166,28 +166,30 @@ struct main_list_y_ptr_STRING * split_str_to_main_list_y_ptr_STRING(char *str_or
|
||||
|
||||
void usage_cmdl(){
|
||||
printf("usage:\n"
|
||||
"help: to print this menu.\n"
|
||||
"kill: to gracefuly kill local socket server.\n"
|
||||
"sendto [addr] { \"cmd\" : \"[command]\" }\n"
|
||||
"addr: ipv4 address or ipv6 address \n"
|
||||
"\tor all to send cmd to all nodes already in the list.\n"
|
||||
"\tor other to send cmd to all nodes excluding local address in the list.\n"
|
||||
"command: \n"
|
||||
"\tupdate kill: to gracefully shutdown socket server.\n"
|
||||
"\tupdate cleanup: to free m_headers lists.\n"
|
||||
"\tupdate standby: to suspend all workers, but can receive all task but in queu tasks.\n"
|
||||
"\tupdate wakeup: to wakeup all workers, and then execute all tasks in queu.\n"
|
||||
"\tpipe: to pipe string after header to destination:\n"
|
||||
"\t\teg: sendto 192.168.1.142 { \"cmd\" : \"pipe\" }sendto 192.168.1.250 { \"cmd\" : \"get file SOME_FILE_LOCAL\" }\n"
|
||||
"\t\tIt is equivalent to type: sendto 192.168.1.250 { \"cmd\" : \"get file SOME_FILE_LOCAL\" }\n\t\tin node 192.168.1.142.\n"
|
||||
"\tupdate remove node [addr]: to remove [addr] in the list.\n"
|
||||
"\tupdate add node [addr]: to add [addr] in the list.\n"
|
||||
"\tget file [filename]: to ask server to send file named [filename].\n"
|
||||
"\t\tfilename can be absolute path or relative working directory path\n"
|
||||
"\t\teg: sendto 192.168.1.142 { \"cmd\" : \"get file FILENAME\" }\n"
|
||||
"\t\twe can specify destination directory eg: sendto 192.168.1.142 { \"cmd\" : \"get file FILENAME\" , \"dst_dir\" : \"DIRECTORY_NEW_OR_ALREADY_EXISTS\" }\n"
|
||||
"\tpost file [filename] : to send file [filename] after header.\n"
|
||||
"\t\tNeed to add \"seq\" and \"tm\" keys to have good handling, the payload is after the header {}\n"
|
||||
"\t\tSee y_socket_send_file_for_node function.\n"
|
||||
"\tpost ok [filenameid]: to acknowledge receipt [filename].\n"
|
||||
"\t\t[filenameid] is to precise witch [filename] (file name from whom and when)\n"
|
||||
"\taddr: server cible address: ipv4 address or ipv6 address \n"
|
||||
"\t\tor all to send cmd to all nodes already in the list.\n"
|
||||
"\t\tor other to send cmd to all nodes excluding local address in the list.\n"
|
||||
"\tcommand: \n"
|
||||
"\t\tupdate kill: to gracefully shutdown socket server.\n"
|
||||
"\t\tupdate cleanup: to free m_headers lists.\n"
|
||||
"\t\tupdate standby: to suspend all workers, but can receive all task but in queu tasks.\n"
|
||||
"\t\tupdate wakeup: to wakeup all workers, and then execute all tasks in queu.\n"
|
||||
"\t\tpipe: to pipe string after header to destination:\n"
|
||||
"\t\t\teg: sendto 192.168.1.142 { \"cmd\" : \"pipe\" }sendto 192.168.1.250 { \"cmd\" : \"get file SOME_FILE_LOCAL\" }\n"
|
||||
"\t\t\tIt is equivalent to type: sendto 192.168.1.250 { \"cmd\" : \"get file SOME_FILE_LOCAL\" }\n\t\tin node 192.168.1.142.\n"
|
||||
"\t\tupdate remove node [addr]: to remove [addr] in the list.\n"
|
||||
"\t\tupdate add node [addr]: to add [addr] in the list.\n"
|
||||
"\t\tget file [filename]: to ask server to send file named [filename].\n"
|
||||
"\t\t\tfilename can be absolute path or relative working directory path\n"
|
||||
"\t\t\teg: sendto 192.168.1.142 { \"cmd\" : \"get file FILENAME\" }\n"
|
||||
"\t\t\twe can specify destination directory eg: sendto 192.168.1.142 { \"cmd\" : \"get file FILENAME\" , \"dst_dir\" : \"DIRECTORY_NEW_OR_ALREADY_EXISTS\" }\n"
|
||||
"\t\tpost file [filename] : to send file [filename] after header.\n"
|
||||
"\t\t\tNeed to add \"seq\" and \"tm\" keys to have good handling, the payload is after the header {}\n"
|
||||
"\t\t\tSee y_socket_send_file_for_node function.\n"
|
||||
"\t\tpost ok [filenameid]: to acknowledge receipt [filename].\n"
|
||||
"\t\t\t[filenameid] is to precise witch [filename] (file name from whom and when)\n"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -587,7 +587,13 @@ if(buf_len>6){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(buf_len && strncmp(buf, "help", 4)==0){
|
||||
usage_cmdl();
|
||||
}else if(buf_len && strncmp(buf, "kill", 4)==0){
|
||||
pthread_mutex_lock(argSock->mut_go_on);
|
||||
argSock->go_on = 0;
|
||||
pthread_mutex_unlock(argSock->mut_go_on);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -190,12 +190,12 @@ TEST(pollThread){
|
||||
|
||||
wait_var_set_up_value_not_equal(var, 0);
|
||||
EXPECT_EQ(var->set_up,1);
|
||||
|
||||
/*
|
||||
char buf[] = "sendto 192.168.1.250 { \"cmd\" : \"get file __exode.txt\" }";
|
||||
size_t len_buf = strlen(buf);
|
||||
|
||||
set_cmd_to_socket(buf, len_buf, var);
|
||||
|
||||
*/
|
||||
/*
|
||||
struct argdst dstarg={
|
||||
.port="1600",
|
||||
|
||||
Reference in New Issue
Block a user