00001
00002
00003
00004 #define DRMS_CLIENT
00005
00006 #include "jsoc.h"
00007 #include "drms.h"
00008 #ifdef DEBUG_MEM
00009 #include "xmem.h"
00010 #endif
00011 #include "tee.h"
00012 #include <signal.h>
00013
00014 #include "serverdefs.h"
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <time.h>
00018 #include <errno.h>
00019
00020 #include "cfortran.h"
00021 #include "jsoc_main.h"
00022 #include "drms_env.h"
00023 #include "cmdparams_priv.h"
00024
00025 CmdParams_t cmdparams;
00026
00027 DRMS_Env_t *drms_env;
00028
00029 #ifndef FLIB
00030
00031
00032
00033
00034 ModuleArgs_t *gModArgs = module_args;
00035 #endif
00036
00037 CmdParams_t *GetGlobalCmdParams()
00038 {
00039 return &cmdparams;
00040 }
00041
00042
00043 const char *mn = NULL;
00044
00045 static pid_t drms_start_server (int verbose, int dolog);
00046
00047
00048 static void atexit_action (void) {
00049 fprintf (stderr, "WARNING: DRMS module %s called exit.\nThe DRMS session"
00050 " will be aborted and the database rolled back.\n", mn);
00051 }
00052
00053 static int FreeCmdparams(void *data)
00054 {
00055 cmdparams_freeall(&cmdparams);
00056 memset(&cmdparams, 0, sizeof(CmdParams_t));
00057 return 0;
00058 }
00059
00060 int JSOCMAIN_Init(int argc,
00061 char **argv,
00062 const char *module_name,
00063 int *dolog,
00064 int *verbose,
00065 pid_t *drms_server_pid,
00066 pid_t *tee_pid,
00067 int *cont)
00068 {
00069 int status;
00070 int quiet;
00071 int printrel = 0;
00072 char reservebuf[128];
00073 int selfstart = 0;
00074
00075 if (cont)
00076 {
00077 *cont = 0;
00078 }
00079
00080 mn = module_name;
00081
00082 #ifdef DEBUG_MEM
00083 xmem_config (1, 1, 1, 1, 1000000, 1,0, 0);
00084 #endif
00085
00086 snprintf(reservebuf,
00087 sizeof(reservebuf),
00088 "%s,%s,%s,%s,%s,%s,%s,%s,%s",
00089 "L,Q,V,jsocmodver",
00090 kARCHIVEARG,
00091 kRETENTIONARG,
00092 kNewSuRetention,
00093 kQUERYMEMARG,
00094 kSERVERWAITARG,
00095 kLoopConn,
00096 kDBTimeOut,
00097 kCreateShadows,
00098 kDBUtf8ClientEncoding);
00099 cmdparams_reserve(&cmdparams, reservebuf, "jsocmain");
00100
00101 status = cmdparams_parse (&cmdparams, argc, argv);
00102 if (status == CMDPARAMS_QUERYMODE) {
00103 cmdparams_usage (argv[0]);
00104 return 0;
00105 } else if (status == CMDPARAMS_NODEFAULT) {
00106 fprintf (stderr, "For usage, type %s [-H|--help]\n", argv[0]);
00107 return 0;
00108 } else if (status < 0) {
00109 fprintf (stderr, "Error: Command line parsing failed. Aborting.\n");
00110 fprintf (stderr, "For usage, type %s [-H|--help]\n", argv[0]);
00111 return 1;
00112 }
00113
00114 printrel = cmdparams_isflagset(&cmdparams, "jsocmodver");
00115
00116 if (printrel)
00117 {
00118 char verstr[32];
00119 int isdev = 0;
00120
00121 jsoc_getversion(verstr, sizeof(verstr), &isdev);
00122 fprintf(stdout,
00123 "Module '%s' JSOC version is '%s' (%s)\n",
00124 module_name,
00125 verstr,
00126 isdev ? "development" : "release");
00127 return 0;
00128 }
00129
00130 *verbose = (cmdparams_exists (&cmdparams, "V") &&
00131 cmdparams_get_int (&cmdparams, "V", NULL) != 0);
00132 if (*verbose) cmdparams_printall (&cmdparams);
00133 quiet = (cmdparams_exists (&cmdparams, "Q") &&
00134 cmdparams_get_int (&cmdparams, "Q", NULL) != 0);
00135 *dolog = (cmdparams_exists (&cmdparams, "L") &&
00136 cmdparams_get_int (&cmdparams, "L", NULL) != 0);
00137 if (!cmdparams_exists (&cmdparams, kQUERYMEMARG))
00138 cmdparams_set (&cmdparams, kQUERYMEMARG, "512");
00139
00140 if (!cmdparams_exists (&cmdparams, "DRMSSESSION")) {
00141 if ((*drms_server_pid = drms_start_server (*verbose, *dolog)) < 0) {
00142 fprintf (stderr,
00143 "Couldn't connect to a DRMS server via drms_start_server.\n");
00144 return 1;
00145 }
00146
00147
00148 selfstart = 1;
00149 }
00150
00151 if (cmdparams_exists (&cmdparams, "DRMSSESSION")) {
00152 char filename_e[1024], filename_o[1024];
00153 const char *drmssession = cmdparams_get_str (&cmdparams, "DRMSSESSION", NULL);
00154 const char *jsoc_dbuser = cmdparams_get_str (&cmdparams, "JSOC_DBUSER", NULL);
00155 const char *jsoc_dbpasswd = cmdparams_get_str (&cmdparams, "JSOC_DBPASSWD", NULL);
00156 const char *jsoc_dbname = cmdparams_get_str (&cmdparams, "JSOC_DBNAME", NULL);
00157 drms_env = drms_open (drmssession, jsoc_dbuser, jsoc_dbpasswd, jsoc_dbname, NULL);
00158 if (drms_env == NULL) {
00159 fprintf (stderr, "Couldn't connect to DRMS.\n");
00160 return 1;
00161 }
00162
00163 drms_env->selfstart = selfstart;
00164 drms_env->query_mem = cmdparams_get_int (&cmdparams, kQUERYMEMARG, NULL);
00165
00166 if (*dolog) {
00167 if (save_stdeo()) {
00168 printf ("Can't save stdout and stderr\n");
00169 return 1;
00170 }
00171
00172
00173 CHECKSNPRINTF(snprintf (filename_o, 1023, "%s/%s.%04d.stdout.gz",
00174 drms_env->session->sudir, module_name, drms_env->session->clientid), 1023);
00175 CHECKSNPRINTF(snprintf (filename_e, 1023, "%s/%s.%04d.stderr.gz",
00176 drms_env->session->sudir, module_name, drms_env->session->clientid), 1023);
00177
00178 if (!quiet) {
00179 if ((*tee_pid = tee_stdio (filename_o, 0644, filename_e, 0644)) < 0)
00180 return -1;
00181 } else if (redirect_stdio (filename_o, 0644, filename_e, 0644))
00182 return -1;
00183 }
00184 #ifndef IDLLIB
00185
00186
00187
00188
00189
00190
00191
00192
00193 atexit (atexit_action);
00194 #endif
00195 }
00196
00197
00198
00199
00200
00201 #ifndef DEBUG
00202 sigemptyset(&drms_env->signal_mask);
00203 sigaddset(&drms_env->signal_mask, SIGINT);
00204 sigaddset(&drms_env->signal_mask, SIGQUIT);
00205 sigaddset(&drms_env->signal_mask, SIGTERM);
00206 sigaddset(&drms_env->signal_mask, SIGUSR1);
00207 sigaddset(&drms_env->signal_mask, SIGUSR2);
00208
00209 if( (status = pthread_sigmask(SIG_BLOCK, &drms_env->signal_mask, &drms_env->old_signal_mask)))
00210 {
00211 fprintf(stderr,"pthread_sigmask call failed with status = %d\n", status);
00212 exit(1);
00213 }
00214
00215 drms_env->main_thread = pthread_self();
00216
00217
00218
00219 CleanerData_t cleaner = {(pFn_Cleaner_t)FreeCmdparams, (void *)NULL};
00220
00221 drms_client_registercleaner(drms_env, &cleaner);
00222
00223
00224
00225 if( (status = pthread_create(&drms_env->signal_thread, NULL, &drms_signal_thread,
00226 (void *) drms_env)) )
00227 {
00228 fprintf(stderr,"Thread creation failed: %d\n", status);
00229 exit(1);
00230 }
00231
00232 #endif
00233
00234
00235 if (cont)
00236 {
00237 *cont = 1;
00238 }
00239
00240 return 0;
00241 }
00242
00243 int JSOCMAIN_Term(int dolog, int verbose, pid_t drms_server_pid, pid_t tee_pid, int abort_flag)
00244 {
00245 int status;
00246
00247 #ifdef DEBUG
00248 printf ("Module %s returned with status = %d\n", mn, abort_flag);
00249 #endif
00250
00251
00252
00253
00254 if (!abort_flag)
00255 {
00256 drms_fitsrw_term(drms_env->verbose);
00257 }
00258
00259
00260
00261
00262
00263
00264
00265 if (cmdparams_exists (&cmdparams, "DRMSSESSION")) {
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 if (abort_flag) drms_abort (drms_env);
00278 else drms_close (drms_env, DRMS_INSERT_RECORD);
00279 }
00280
00281 if (dolog) {
00282 fclose (stdout);
00283 fclose (stderr);
00284 if (tee_pid) {
00285 waitpid (tee_pid, &status, 0);
00286 if (status) printf ("Problem returning from tee\n");
00287 }
00288 if (restore_stdeo ()) printf ("Can't restore stderr and stdout\n");
00289 }
00290
00291 if (drms_server_pid) {
00292
00293 if (abort_flag) {
00294 if (verbose)
00295 printf ("Command returned an error code. Rolling back database.\n");
00296 kill (drms_server_pid, SIGTERM);
00297 }
00298 else {
00299 if (verbose)
00300 printf ("Command finished successfully. Commiting data to database.\n");
00301 if (kill (drms_server_pid, SIGUSR1)) {
00302 perror ("SIGUSR1 attempt failed to stop server jsoc_main");
00303 printf ("drms_pid = %d\n", drms_server_pid);
00304 }
00305 }
00306 if (waitpid (drms_server_pid, &status, 0) < 0) perror ("waitpid error");
00307 if (verbose) printf ("drms_server returned with status = %d\n", status);
00308 }
00309
00310 cmdparams_freeall (&cmdparams);
00311
00312 #ifdef DEBUG_MEM
00313 xmem_leakreport ();
00314 #endif
00315 fflush (stdout);
00316 fflush (stderr);
00317
00318 return status;
00319 }
00320
00321 int JSOCMAIN_Main(int argc, char **argv, const char *module_name, int (*CallDoIt)(void))
00322 {
00323 int abort_flag = 0;
00324 int cont;
00325 int ret;
00326
00327
00328 int dolog;
00329 int verbose;
00330 pid_t drms_server_pid = 0;
00331 pid_t tee_pid = 0;
00332
00333
00334 ret = JSOCMAIN_Init(argc,
00335 argv,
00336 module_name,
00337 &dolog,
00338 &verbose,
00339 &drms_server_pid,
00340 &tee_pid,
00341 &cont);
00342
00343 if (!cont)
00344 {
00345 return ret;
00346 }
00347
00348
00349 if (CallDoIt)
00350 {
00351 abort_flag = (*CallDoIt)();
00352 }
00353
00354 sem_t *sdsem = drms_client_getsdsem();
00355
00356 if (sdsem)
00357 {
00358 sem_wait(sdsem);
00359 }
00360
00361 if (drms_client_getsd() != kSHUTDOWN_UNINITIATED)
00362 {
00363
00364
00365 if (sdsem)
00366 {
00367 sem_post(sdsem);
00368 }
00369
00370 pthread_join(drms_env->signal_thread, NULL);
00371 }
00372 else
00373 {
00374
00375 drms_client_setsd(kSHUTDOWN_BYMAIN);
00376
00377 if (sdsem)
00378 {
00379 sem_post(sdsem);
00380 }
00381
00382 JSOCMAIN_Term(dolog, verbose, drms_server_pid, tee_pid, abort_flag);
00383 }
00384
00385 return(abort_flag);
00386 }
00387
00388
00389
00390 pid_t drms_start_server (int verbose, int dolog) {
00391 const char *dbhost;
00392 char *dbuser, *dbpasswd, *dbname, *sessionns;
00393 char *dbport = NULL;
00394 char dbHostAndPort[64];
00395 int query_mem, server_wait;
00396 int16_t retention;
00397 int16_t newsuretention;
00398 int archive;
00399 int dbtimeout;
00400 int loopconn;
00401 int createshadows = 0;
00402 int dbutf8clientencoding = 0;
00403 char drms_session[DRMS_MAXPATHLEN];
00404 char drms_host[DRMS_MAXPATHLEN];
00405 char drms_port[DRMS_MAXPATHLEN];
00406 int status = 0;
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424 if ((dbhost = cmdparams_get_str (&cmdparams, "JSOC_DBHOST", NULL)) == NULL)
00425 {
00426 const char *sep = NULL;
00427
00428 dbhost = SERVER;
00429 dbport = DRMSPGPORT;
00430
00431
00432 if ((sep = strchr(dbhost, ':')) != NULL)
00433 {
00434 if (strcmp(sep + 1, dbport) != 0)
00435 {
00436 char *tmpBuf = strdup(dbhost);
00437
00438 if (tmpBuf)
00439 {
00440 tmpBuf[sep - dbhost] = '\0';
00441 fprintf(stderr, "WARNING: the port number in the SERVER localization parameter (%s) and in DRMSPGPORT (%s) conflict.\nThe DRMSPGPORT value will be used.\n", sep + 1, DRMSPGPORT);
00442
00443 snprintf(dbHostAndPort, sizeof(dbHostAndPort), "%s:%s", tmpBuf, dbport);
00444 free(tmpBuf);
00445 tmpBuf = NULL;
00446 }
00447 else
00448 {
00449 fprintf(stderr, "Out of memory.\n");
00450 return 1;
00451 }
00452 }
00453 else
00454 {
00455 snprintf(dbHostAndPort, sizeof(dbHostAndPort), "%s", dbhost);
00456 }
00457 }
00458 else
00459 {
00460 snprintf(dbHostAndPort, sizeof(dbHostAndPort), "%s:%s", dbhost, dbport);
00461 }
00462 }
00463 else
00464 {
00465 snprintf(dbHostAndPort, sizeof(dbHostAndPort), "%s", dbhost);
00466 }
00467
00468 if ((dbname = cmdparams_get_str (&cmdparams, "JSOC_DBNAME", NULL)) == NULL)
00469 dbname = DBNAME;
00470 if ((dbuser = cmdparams_get_str (&cmdparams, "JSOC_DBUSER", NULL)) == NULL)
00471 dbuser = USER;
00472 if ((dbpasswd = cmdparams_get_str (&cmdparams, "JSOC_DBPASSWD", NULL)) == NULL)
00473 dbpasswd = PASSWD;
00474 sessionns = cmdparams_get_str (&cmdparams, "JSOC_SESSIONNS", NULL);
00475
00476 archive = INT_MIN;
00477 if (drms_cmdparams_exists(&cmdparams, kARCHIVEARG)) {
00478 archive = drms_cmdparams_get_int(&cmdparams, kARCHIVEARG, NULL);
00479 }
00480
00481 char errbuf[128];
00482
00483 retention = INT16_MIN;
00484 if (drms_cmdparams_exists(&cmdparams, kRETENTIONARG))
00485 {
00486 retention = drms_cmdparams_get_int16(&cmdparams, kRETENTIONARG, &status);
00487 if (status != DRMS_SUCCESS)
00488 {
00489 if (status == DRMS_ERROR_INVALIDCMDARGCONV)
00490 {
00491 snprintf(errbuf, sizeof(errbuf), "The value for %s must be a 15-bit positive integer.", kRETENTIONARG);
00492 fprintf(stderr, errbuf);
00493 }
00494
00495 snprintf(errbuf, sizeof(errbuf), "Invalid value for %s.", kRETENTIONARG);
00496 fprintf(stderr, errbuf);
00497 return 1;
00498 }
00499 else if (retention < 0)
00500 {
00501 snprintf(errbuf, sizeof(errbuf), "The value for %s must be a 15-bit positive integer.", kRETENTIONARG);
00502 fprintf(stderr, errbuf);
00503 return 1;
00504 }
00505 else
00506 {
00507 retention = (int16_t)(retention & 0x7FFF);
00508 }
00509 }
00510
00511 newsuretention = INT16_MIN;
00512 if (drms_cmdparams_exists(&cmdparams, kNewSuRetention))
00513 {
00514 newsuretention = drms_cmdparams_get_int16(&cmdparams, kNewSuRetention, &status);
00515 if (status != DRMS_SUCCESS)
00516 {
00517 if (status == DRMS_ERROR_INVALIDCMDARGCONV)
00518 {
00519 snprintf(errbuf, sizeof(errbuf), "The value for %s must be a 15-bit positive integer.", kNewSuRetention);
00520 fprintf(stderr, errbuf);
00521 }
00522
00523 snprintf(errbuf, sizeof(errbuf), "Invalid value for %s.", kNewSuRetention);
00524 fprintf(stderr, errbuf);
00525 return 1;
00526 }
00527 else if (newsuretention < 0)
00528 {
00529 snprintf(errbuf, sizeof(errbuf), "The value for %s must be a 15-bit positive integer.", kNewSuRetention);
00530 fprintf(stderr, errbuf);
00531 return 1;
00532 }
00533 else
00534 {
00535 newsuretention = (int16_t)(newsuretention & 0x7FFF);
00536 }
00537 }
00538
00539 query_mem = 512;
00540 if (cmdparams_exists (&cmdparams, kQUERYMEMARG))
00541 query_mem = cmdparams_get_int (&cmdparams, kQUERYMEMARG, NULL);
00542
00543 server_wait = 0;
00544 if (cmdparams_exists (&cmdparams, kSERVERWAITARG))
00545 server_wait = cmdparams_get_int (&cmdparams, kSERVERWAITARG, NULL);
00546
00547 dbtimeout = INT_MIN;
00548 if (drms_cmdparams_exists(&cmdparams, kDBTimeOut))
00549 {
00550 dbtimeout = drms_cmdparams_get_int(&cmdparams, kDBTimeOut, NULL);
00551 }
00552
00553 dbutf8clientencoding = 0;
00554 if (drms_cmdparams_exists(&cmdparams, kDBUtf8ClientEncoding))
00555 {
00556 dbutf8clientencoding = drms_cmdparams_get_int(&cmdparams, kDBUtf8ClientEncoding, NULL);
00557 }
00558
00559 loopconn = cmdparams_isflagset(&cmdparams, kLoopConn);
00560 createshadows = cmdparams_isflagset(&cmdparams, kCreateShadows);
00561
00562 int fd[2];
00563 pid_t pid;
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574 if (pipe(fd) < 0) {
00575 perror("pipe error");
00576 return -1;
00577 }
00578
00579 if ( (pid = fork()) < 0) {
00580 perror("fork error");
00581 return -1;
00582 }
00583 else if (pid > 0) {
00584 close(fd[1]);
00585
00586 const int bufsz = 1024;
00587 char *server_info = 0, *line = 0;
00588 server_info = malloc(bufsz);
00589 XASSERT(server_info);
00590 line = malloc(bufsz);
00591 XASSERT(line);
00592 server_info[0] = '\0';
00593 int n;
00594 fd_set readfd;
00595 do {
00596 FD_ZERO(&readfd);
00597 FD_SET(fd[0], &readfd);
00598 if (select(fd[0]+1, &readfd, NULL, NULL, NULL) < 0) {
00599 if (errno == EINTR)
00600 continue;
00601 else
00602 {
00603 perror("Select failed");
00604 return -1;
00605 }
00606 }
00607 if ((n = read(fd[0], line, bufsz)) < 0) {
00608 perror("Read error from pipe");
00609 return -1;
00610 }
00611 if (n) {
00612 line[n] = '\0';
00613 if (strstr(line, "failed")) {
00614 return -1;
00615 }
00616 strcat(server_info, line);
00617 }
00618
00619 } while (!strstr(line, "__ENDSELFSTART__"));
00620 if (verbose) {
00621 write(STDOUT_FILENO, server_info, strlen(server_info));
00622 }
00623
00624 char *p = strstr(server_info, "DRMS_HOST");
00625 sscanf(p, "DRMS_HOST = %s", drms_host);
00626 p = strstr(server_info, "DRMS_PORT");
00627 sscanf(p, "DRMS_PORT = %s", drms_port);
00628 strcpy(drms_session, drms_host);
00629 strcat(drms_session, ":");
00630 strcat(drms_session, drms_port);
00631
00632 cmdparams_set(&cmdparams, "DRMSSESSION", drms_session);
00633 free(server_info);
00634 free(line);
00635 return pid;
00636 } else {
00637 close(fd[0]);
00638
00639 if (fd[1] != STDOUT_FILENO) {
00640 if (dup2(fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
00641 perror ("dup2 error to stdout");
00642 exit (1);
00643 }
00644 close(fd[1]);
00645 }
00646
00647 const int num_args = 20;
00648 char **argv = malloc(num_args*sizeof(char *));
00649 int i = 0;
00650 argv[i++] = strdup ("drms_server");
00651 argv[i++] = strdup ("-f");
00652 argv[i++] = strdup ("-b");
00653 if (verbose)
00654 argv[i++] = strdup ("-V");
00655 if (dolog)
00656 argv[i++] = strdup ("-L");
00657 argv[i] = malloc (strlen (dbHostAndPort)+DRMS_MAXNAMELEN);
00658 sprintf (argv[i++], "JSOC_DBHOST=%s", dbHostAndPort);
00659 argv[i] = malloc (strlen (dbname)+DRMS_MAXNAMELEN);
00660 sprintf (argv[i++], "JSOC_DBNAME=%s", dbname);
00661 if (dbuser) {
00662 argv[i] = malloc (strlen (dbuser)+DRMS_MAXNAMELEN);
00663 sprintf (argv[i++], "JSOC_DBUSER=%s", dbuser);
00664 }
00665 if (dbpasswd) {
00666 argv[i] = malloc (strlen (dbpasswd)+DRMS_MAXNAMELEN);
00667 sprintf(argv[i++], "JSOC_DBPASSWD=%s", dbpasswd);
00668 }
00669 if (sessionns) {
00670 argv[i] = malloc (strlen (sessionns)+DRMS_MAXNAMELEN);
00671 sprintf (argv[i++], "JSOC_SESSIONNS=%s", sessionns);
00672 }
00673 if (archive == -1 || archive == 0 || archive == 1) {
00674 argv[i] = malloc (DRMS_MAXNAMELEN*2);
00675 sprintf (argv[i++], "%s=%d", kARCHIVEARG, archive);
00676 }
00677 if (retention > 0) {
00678 argv[i] = malloc (DRMS_MAXNAMELEN*2);
00679 sprintf (argv[i++], "%s=%d", kRETENTIONARG, retention);
00680 }
00681 if (newsuretention > 0)
00682 {
00683 argv[i] = malloc(DRMS_MAXNAMELEN*2);
00684 snprintf(argv[i++], DRMS_MAXNAMELEN*2, "%s=%d", kNewSuRetention, newsuretention);
00685 }
00686 if (query_mem != 512) {
00687 argv[i] = malloc (DRMS_MAXNAMELEN*2);
00688 sprintf (argv[i++], "%s=%d", kQUERYMEMARG, query_mem);
00689 }
00690 if (!server_wait) {
00691 argv[i] = malloc (DRMS_MAXNAMELEN*2);
00692 sprintf (argv[i++], "%s=%d", kSERVERWAITARG, server_wait);
00693 }
00694
00695 if (INT_MIN != dbtimeout)
00696 {
00697 argv[i] = malloc (DRMS_MAXNAMELEN*2);
00698 sprintf (argv[i++], "%s=%d", kDBTimeOut, dbtimeout);
00699 }
00700
00701 if (loopconn)
00702 {
00703 char buf[256];
00704
00705 snprintf(buf, sizeof(buf), "--%s", kLoopConn);
00706 argv[i++] = strdup(buf);
00707 }
00708
00709 if (createshadows)
00710 {
00711 char buf[256];
00712
00713 snprintf(buf, sizeof(buf), "--%s", kCreateShadows);
00714 argv[i++] = strdup(buf);
00715 }
00716
00717 if (dbutf8clientencoding)
00718 {
00719 argv[i] = malloc(DRMS_MAXNAMELEN * 2);
00720 snprintf(argv[i++], DRMS_MAXNAMELEN * 2, "%s=1", kDBUtf8ClientEncoding);
00721 }
00722
00723 for (; i < num_args; i++) {
00724 argv[i] = NULL;
00725 }
00726
00727 if (verbose)
00728 {
00729 fprintf(stderr, "Calling drms_server with args:\n");
00730
00731 for (i = 0; i < num_args; i++)
00732 {
00733 fprintf(stderr, "\t%s\n", argv[i]);
00734 }
00735 }
00736
00737 if (execvp ("drms_server", argv) < 0) {
00738 printf ("drms_start_server failed to start server.\n");
00739 perror ("exec error for drms_server");
00740 exit (1);
00741 }
00742 }
00743
00744 if (verbose) {
00745 if (!dolog) printf ("Log Files not copied to DRMS_SUDIR\n");
00746 printf ("Starting command now.\n");
00747 }
00748
00749 return(0);
00750
00751 }
00752