Changeset 854 for branches/prototype-v0/zoo-project/zoo-services
- Timestamp:
- Nov 21, 2017, 10:24:14 AM (7 years ago)
- Location:
- branches/prototype-v0/zoo-project/zoo-services
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-services/gdal/dem/cgi-env/Gdal_Dem.zcfg
r412 r854 44 44 <Default /> 45 45 </LiteralData> 46 [co] 47 Title = Creation Option 48 Abstract = string representing options (NAME=VALUE) 49 minOccurs = 0 50 maxOccurs = 1 51 <LiteralData> 52 DataType = string 53 <Default /> 54 </LiteralData> 46 55 </DataInputs> 47 56 <DataOutputs> -
branches/prototype-v0/zoo-project/zoo-services/gdal/dem/service.c
r444 r854 2486 2486 setMapInMaps(outputs,"Result","value",tmpMap->value); 2487 2487 } 2488 2489 tmpMap=getMapFromMaps(inputs,"co","value"); 2490 if(tmpMap!=NULL){ 2491 papszCreateOptions = CSLAddString( papszCreateOptions, tmpMap->value ); 2492 map* tmpMap1; 2493 maps* tmpMaps=getMaps(inputs,"co"); 2494 if((tmpMap1=getMapFromMaps(inputs,"co","length"))!=NULL){ 2495 int i=1; 2496 int length=atoi(tmpMap1->value); 2497 for(;i<length;i++){ 2498 tmpMap=getMapArray(tmpMaps->content,"value",i); 2499 papszCreateOptions = CSLAddString( papszCreateOptions, tmpMap->value ); 2500 } 2501 } 2502 } 2488 2503 2489 2504 tmpMap=NULL; -
branches/prototype-v0/zoo-project/zoo-services/utils/hpc/Makefile
r839 r854 4 4 5 5 cgi-env/wps_hpc.zo: service.c 6 g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_hpc.zo ./service.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${ZRPATH}/zoo-kernel/ -lzoo_service ${ZRPATH}/zoo-kernel/sshapi.o ${HPCLDFLAGS}6 g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_hpc.zo service.c service2.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${ZRPATH}/zoo-kernel/ -lzoo_service ${ZRPATH}/zoo-kernel/sshapi.o ${HPCLDFLAGS} 7 7 8 8 install: -
branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service.c
r839 r854 3 3 * 4 4 * Copyright 2008-2009 GeoLabs SARL. All rights reserved. 5 * 6 * This work was supported by public funds received in the framework of GEOSUD, 7 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed 8 * by the French National Research Agency 5 9 * 6 10 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 27 31 #include "service_internal.h" 28 32 #include "sshapi.h" 33 #include "server_internal.h" 29 34 30 35 #include <sys/socket.h> … … 57 62 int fd,rc=NULL; 58 63 int i=0; 64 map* usid=getMapFromMaps(conf,"lenv","usid"); 65 map* tmpPath=getMapFromMaps(conf,"main","tmpPath"); 66 67 char *flenv = 68 (char *) malloc ((strlen (tmpPath->value) + 69 strlen (jobid->value) + 12) * sizeof (char)); 70 sprintf (flenv, "%s/%s_lenv.cfg", tmpPath->value, jobid->value); 71 maps* m = (maps *) malloc (MAPS_SIZE); 72 m->child=NULL; 73 m->next=NULL; 74 map* configId=NULL; 75 76 77 if(conf_read(flenv, m) != 2){ 78 configId=getMapFromMaps(m,"lenv","configId"); 79 setMapInMaps(conf,"lenv","configId",configId->value); 80 }else{ 81 setMapInMaps(conf,"lenv","message",_("Unable to read the lenv section file of the requested jobid")); 82 return SERVICE_FAILED; 83 } 84 unlink(flenv); 85 free(flenv); 86 59 87 SSHCON *test=ssh_connect(conf); 60 88 if(test==NULL){ 61 return SERVICE_FAILED;62 }63 map* usid=getMapFromMaps(conf,"lenv","usid");64 map* tmpPath=getMapFromMaps(conf,"main","tmpPath"); 89 setMapInMaps(conf,"lenv","message",_("Unable to connect using through ssh.")); 90 return SERVICE_FAILED; 91 } 92 65 93 char *logPath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+12)*sizeof(char)); 66 94 sprintf(logPath,"%s/exec_out_%s",tmpPath->value,jobid->value); … … 80 108 } 81 109 free(logPath); 82 // Run scontrol to see if the service execution ends110 // Run scontrol to check if the service execution ended. 83 111 // Store all the informations returned by scontrol command as a cfg file to 84 112 // be parsed back by the ZOO-Kernel waiting for the execution of the remote … … 86 114 maps* tmpMaps=createMaps("henv"); 87 115 char* command=(char*)malloc((126)*sizeof(char)); 88 //memset(&command,0,34); 89 sprintf(command,"scontrol show jobid | grep -A24 %s",fcontent); 116 sprintf(command,"scontrol show jobid | grep -A24 JobId=%s",fcontent); 90 117 if(ssh_exec(conf,command,ssh_get_cnt(conf))==0){ 91 118 free(command); 92 119 setMapInMaps(conf,"lenv","message",_("Failed to run scontrol remotely")); 120 // TODO: check status in db and if available continue in other case return SERVICE_FAILED 93 121 return SERVICE_FAILED; 94 122 }else{ … … 98 126 int ts=stat(logPath, &f_status); 99 127 if(ts==0) { 100 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 101 FILE* f=fopen(logPath,"rb"); 102 fread(fcontent,f_status.st_size,1,f); 103 int fsize=f_status.st_size; 104 fcontent[fsize]=0; 105 fclose(f); 106 free(logPath); 107 fprintf(stderr,"%s \n",fcontent); 108 char *token, *saveptr; 109 token = strtok_r (fcontent, " ", &saveptr); 110 while (token != NULL) 111 { 112 //fprintf(stderr,"%s %d\n",token,__LINE__); 113 char *token1, *saveptr1; 114 char *tmpToken=strdup(token); 115 token1 = strtok_r (tmpToken, "=", &saveptr1); 116 int isNext=-1; 117 int hasTwoElements=0; 118 char *name=NULL; 119 while (token1 != NULL) 120 { 121 if(hasTwoElements==0) 122 name=strdup(token1); 123 if(hasTwoElements<1) 124 hasTwoElements+=1; 125 else{ 126 char *value=strdup(token1); 127 if(value[strlen(value)-1]=='\n') 128 value[strlen(value)-1]=0; 129 if(strlen(name)>0 && strlen(value)>0){ 130 if(tmpMaps->content==NULL) 131 tmpMaps->content=createMap(name,value); 132 else 133 addToMap(tmpMaps->content,name,value); 134 free(value); 135 } 136 free(name); 137 hasTwoElements=0; 138 } 139 token1 = strtok_r (NULL, "=", &saveptr1); 140 } 141 free(tmpToken); 142 token = strtok_r (NULL, " ", &saveptr); 143 } 128 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 129 FILE* f=fopen(logPath,"rb"); 130 fread(fcontent,f_status.st_size,1,f); 131 int fsize=f_status.st_size; 132 fcontent[fsize]=0; 133 fclose(f); 134 free(logPath); 135 char *token, *saveptr; 136 token = strtok_r (fcontent, " ", &saveptr); 137 while (token != NULL) 138 { 139 char *token1, *saveptr1; 140 char *tmpToken=strdup(token); 141 token1 = strtok_r (tmpToken, "=", &saveptr1); 142 int isNext=-1; 143 int hasTwoElements=0; 144 char *name=NULL; 145 while (token1 != NULL) 146 { 147 if(hasTwoElements==0) 148 name=strdup(token1); 149 if(hasTwoElements<1) 150 hasTwoElements+=1; 151 else{ 152 char *value=strdup(token1); 153 if(value[strlen(value)-1]=='\n') 154 value[strlen(value)-1]=0; 155 if(strlen(name)>0 && strlen(value)>0){ 156 if(tmpMaps->content==NULL) 157 tmpMaps->content=createMap(name,value); 158 else 159 addToMap(tmpMaps->content,name,value); 160 free(value); 161 } 162 free(name); 163 hasTwoElements=0; 164 } 165 token1 = strtok_r (NULL, "=", &saveptr1); 166 } 167 free(tmpToken); 168 token = strtok_r (NULL, " ", &saveptr); 169 } 144 170 }else{ 145 146 171 setMapInMaps(conf,"lenv","message",_("Unable to access the downloaded execution log file")); 172 return SERVICE_FAILED; 147 173 } 148 174 } 149 logPath=(char*)malloc((strlen(tmpPath->value)+strlen(usid->value)+15)*sizeof(char)); 150 sprintf(logPath,"%s/exec_status_%s",tmpPath->value,usid->value); 151 dumpMapsToFile(tmpMaps,logPath,0); 152 153 char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+21)); 154 sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,jobid->value); 155 if ( (fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { 156 perror("socket error"); 157 setMapInMaps(conf,"lenv","message",_("Socket error")); 158 return SERVICE_FAILED; 159 } 160 } 161 logPath=(char*)malloc((strlen(tmpPath->value)+strlen(usid->value)+15)*sizeof(char)); 162 sprintf(logPath,"%s/exec_status_%s",tmpPath->value,usid->value); 175 logPath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char)); 176 sprintf(logPath,"%s/exec_status_%s",tmpPath->value,jobid->value); 163 177 dumpMapsToFile(tmpMaps,logPath,0); 164 178 char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+21)); … … 179 193 if (write(fd, "3", 1) != rc) { 180 194 if (rc < 0) { 181 182 183 184 195 perror("write error"); 196 setMapInMaps(conf,"lenv","message",_("Unable to announce the successful execution of the HPC service")); 197 close(fd); 198 return SERVICE_FAILED; 185 199 } 186 200 } -
branches/prototype-v0/zoo-project/zoo-services/utils/status/Makefile
r811 r854 4 4 5 5 cgi-env/wps_status.zo: service.c 6 g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${ZRPATH}/zoo-kernel/ -lzoo_service6 g++ -rdynamic ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${ZRPATH}/zoo-kernel/ -lzoo_service 7 7 8 8 install:
Note: See TracChangeset
for help on using the changeset viewer.