54 #if defined(AISC_MAGIC_NUMBER)
55 # undef AISC_MAGIC_NUMBER
66 : link(
NULp), com(0x10000*1)
90 arb_assert((remotePrefix[0] == 0) || (strchr(remotePrefix, 0)[-1] ==
'/'));
94 if (host && host[0]) {
95 const char *hostPort = strchr(host,
':');
101 free(quotedRemoteCommand);
125 free(quotedDaemonizingCall);
142 const char *server = strchr(tcp_id, 0) + 1;
143 char *serverparams =
NULp;
151 const char *param = strchr(server, 0)+1;
152 size_t plen = strlen(param);
158 plen = strlen(param);
163 char *sp = serverparams;
165 param = strchr(server, 0)+1;
166 plen = strlen(param);
169 memcpy(sp, param, plen);
173 plen = strlen(param);
181 const char *port = strchr(tcp_id,
':');
184 error =
GB_export_errorf(
"Error: Missing ':' in socket definition of '%s' in file $(ARBHOME)/lib/arb_tcp.dat", arb_tcp_env);
190 const char *serverlog =
GB_getenv(
"ARB_SERVER_LOG");
210 serverctrl->
link =
aisc_open(tcp_id, serverctrl->
com, magic_number, &error);
212 if (!error && !serverctrl->
link) {
214 while (!error && !serverctrl->
link && wait) {
217 if ((wait%10) == 0 && wait>0) {
218 printf(
"Waiting for server '%s' to come up (%i seconds left)\n", arb_tcp_env, wait);
220 serverctrl->
link =
aisc_open(tcp_id, serverctrl->
com, magic_number, &error);
233 if (strcmp(arb_tcp_env,
"ARB_PT_SERVER-1") == 0) {
234 return "No pt-server has been selected.";
245 const char *
arb_tcp_dat =
"$(ARBHOME)/lib/arb_tcp.dat";
254 error =
GBS_global_string(
"Parameter -d missing for entry '%s' in %s", arb_tcp_env, arb_tcp_dat);
257 if (strcmp(file,
"!ASSUME_RUNNING") == 0) {
262 if (strncmp(arb_tcp_env,
"ARB_NAME_SERVER", 15) == 0) {
264 char *lastSlash = strrchr(dir,
'/');
269 const char *copy_cmd =
GBS_global_string(
"cp %s/names.dat.template %s", dir, file);
273 error =
GBS_global_string(
"Cannot copy nameserver template (%s/names.dat.template missing?)", dir);
281 else if (strncmp(arb_tcp_env,
"ARB_PT_SERVER", 13) == 0) {
282 const char *nameOnly = strrchr(file,
'/');
283 if (!nameOnly) nameOnly = file;
286 " To create it follow these steps:\n"
287 " 1. Start ARB on the whole database you want to use for probe match/design\n"
288 " 2. Go to ARB_NTREE/Probes/PT_SERVER Admin\n"
289 " 3. Select '%s' and press BUILD SERVER\n"
290 " 4. Wait (up to hours, depending on your DB size)\n"
291 " 5. Meanwhile read the help file: PT_SERVER: What Why and How",
295 error =
GBS_global_string(
"The file '%s' is missing. \nUnable to start %s", file, arb_tcp_env);
306 "ARB has problems to start a server! Possible reasons may be one\n"
307 "or several of the following list:\n"
308 "- the tcp_id (socket number) is already used by another program\n"
309 " (doesnt apply to user-specific PTSERVERs; check $ARBHOME/lib/arb_tcp.dat versus /etc/services)\n"
310 "- the server exited with error or has crashed.\n"
311 " In case of PTSERVER, the failure might be caused by:\n"
312 " - missing database in $ARBHOME/lib/pts/* (solution: update ptserver database)\n"
313 " - wrong permissions of $ARBHOME/lib/pts/* (no read access)\n"
314 " If you recently installed a new arb version, arb will continue\n"
315 " to use your previous 'arb_tcp.dat', which might be out-of-date.\n"
316 " Backup and remove it, then restart ARB. If it works now,\n"
317 " compare your old 'arb_tcp.dat' with the new one for changes.\n"
318 "- When using remote servers: login or network problems\n"
342 const char *server = strchr(tcp_id, 0)+1;
352 error =
"Server is not running";
378 printf(
"General server parameters (some maybe unused by this server):\n"
379 " -s<name> sets species name to '<name>'\n"
380 " -e<name> sets extended name to '<name>'\n"
381 " -a<ali> sets alignment to '<ali>'\n"
382 " -d<file> sets default file to '<file>'\n"
383 " -f<field>=<def> sets DB field to '<field>' (using <def> as default)\n"
384 " -r read-only mode\n"
385 " -D<server> sets DB-server to '<server>' [default = ':']\n"
386 " -J<server> sets job-server to '<server>' [default = 'ARB_JOB_SERVER']\n"
387 " -M<server> sets MGR-server to '<server>' [default = 'ARB_MGR_SERVER']\n"
388 " -P<server> sets PT-server to '<server>' [default = 'ARB_PT_SERVER']\n"
389 " -T<[host]:port> sets TCP connection to '<[host]:port>'\n"
402 for (s=d=0; s<*argc; s++) {
403 if (argv[s][0] ==
'-') {
404 switch (argv[s][1]) {
413 eq = strchr(erg->
field,
'=');
424 case 'J': freedup(erg->
job_server, argv[s]+2);
break;
425 case 'D': freedup(erg->
db_server, argv[s]+2);
break;
426 case 'M': freedup(erg->
mgr_server, argv[s]+2);
break;
427 case 'P': freedup(erg->
pt_server, argv[s]+2);
break;
429 const char *ipport = argv[
s]+2;
430 if (ipport[0] ==
':' &&
431 ipport[1] >=
'0' && ipport[1] <=
'9') {
469 #if defined(UNIT_TESTS) && 0
475 void TEST_servercntrl() {
GB_ERROR GBK_system(const char *system_command)
int aisc_close(aisc_com *link, AISC_Object &object)
char * ARB_strdup(const char *str)
GB_ERROR arb_look_and_start_server(long magic_number, const char *arb_tcp_env)
GB_ERROR arb_look_and_kill_server(int magic_number, const char *arb_tcp_env)
static GB_ERROR check_server_selected(const char *arb_tcp_env)
const char * GBS_global_string(const char *templat,...)
char * ARB_strpartdup(const char *start, const char *end)
long GB_size_of_file(const char *path)
GB_ERROR arb_start_server(const char *arb_tcp_env, int do_sleep)
arb_params * arb_trace_argv(int *argc, const char **argv)
void free_arb_params(arb_params *params)
static ArbTcpDat arb_tcp_dat
GB_ERROR GB_await_error()
void arb_print_server_params()
const char * GBS_read_arb_tcp(const char *env)
TYPE * ARB_alloc(size_t nelem)
const char * GBS_scan_arb_tcp_param(const char *ipPort, const char *wantedParam)
char * createCallOnSocketHost(const char *host, const char *remotePrefix, const char *command, SpawnMode spawnmode, const char *logfile)
static GB_ERROR arb_wait_for_server(const char *arb_tcp_env, const char *tcp_id, int magic_number, struct gl_struct *serverctrl, int wait)
#define TEST_REJECT(cond)
static void error(const char *msg)
const char * field_default
void ARB_sleep(int amount, TimeUnit tu)
const char * arb_look_and_start_ptserver(int magic_number, int ptserver_id, GB_ERROR &error)
GB_CSTR GB_getenv(const char *env)
#define make_valgrinded_call(command)
GB_ERROR GB_export_errorf(const char *templat,...)
char * GBK_singlequote(const char *arg)
aisc_com * aisc_open(const char *path, AISC_Object &main_obj, long magic, GB_ERROR *error)
static struct gl_struct glservercntrl
bool GB_host_is_local(const char *hostname)
const char * GBS_ptserver_tag(int id)
void make_async_call(char *&command)
char * GBS_global_string_copy(const char *templat,...)
GB_write_int const char s