- Timestamp:
- Mar 19, 2015, 10:01:11 AM (10 years ago)
- Location:
- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/Makefile.in
r549 r617 13 13 14 14 CFLAGS=@DEB_DEF@ -fpic ${GLIB_CPPFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 15 LDFLAGS= -lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${GLIB_LDFLAGS} ${ PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${YAML_LDFLAGS}15 LDFLAGS= -lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${GLIB_LDFLAGS} ${RABBITMQ_LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${YAML_LDFLAGS} ${JSON_LDFLAGS} ${MYSQL_LDFLAGS} 16 16 17 17 PHPCFLAGS=@PHP_CPPFLAGS@ … … 25 25 PERL_ENABLED=@PERL_ENABLED@ 26 26 PERL_FILE=@PERL_FILE@ 27 28 JSON_LDFLAGS=@JSON_LDFLAGS@ 29 JSON_CPPFLAGS=@JSON_CPPFLAGS@ 30 31 RABBITMQ_LDFLAGS=@RABBITMQ_LDFLAGS@ 32 RABBITMQ_CPPFLAGS=@RABBITMQ_CPPFLAGS@ 33 34 MYSQL_LDFLAGS=@MYSQL_LDFLAGS@ 35 MYSQL_CPPFLAGS=@MYSQL_CPPFLAGS@ 36 27 37 28 38 … … 62 72 g++ ${GLIB_CPPFLAGS} ${XML2CFLAGS} -c service_zcfg.c 63 73 74 zoo_json.o: zoo_json.c service.h 75 g++ ${JSON_CPPFLAGS} ${XML2CFLAGS} -c zoo_json.c 76 77 zoo_amqp.o: zoo_amqp.c 78 g++ ${CFLAGS} -c zoo_amqp.c 79 80 zoo_sql.o: zoo_sql.c 81 g++ ${MYSQL_CPPFLAGS} -c zoo_sql.c 82 83 64 84 service_internal.o: service_internal.c service.h 65 85 g++ ${GDAL_CFLAGS} ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service_internal.c … … 93 113 94 114 zoo_service_loader.o: zoo_service_loader.c service.h 95 g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o115 g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} ${JSON_CPPFLAGS} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o 96 116 97 zoo_loader.cgi: version.h zoo_loader.c service_zcfg.o zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE}98 g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${RUBYCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o99 g++ ${JSCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_ loader.o service_zcfg.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}117 zoo_loader.cgi: version.h zoo_loader.c zoo_sql.o zoo_amqp.o zoo_json.o service_zcfg.o zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} 118 g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${RUBYCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} ${JSON_CPPFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o 119 g++ ${JSCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_sql.o zoo_amqp.o zoo_json.o zoo_loader.o service_zcfg.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS} 100 120 101 121 zcfg2yaml: zcfg2yaml.c ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${JS_FILE} ${RUBY_FILE} ${YAML_FILE} -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/bdd/schema.sql
r616 r617 8 8 end_date DATETIME, 9 9 progress int, 10 info TEXT 10 info TEXT, 11 identifier TEXT 11 12 ); 12 13 -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/configure.ac
r549 r617 15 15 AC_CHECK_LIB([pthread], [main]) 16 16 AC_CHECK_LIB([ssl], [main]) 17 17 18 18 19 # Checks for header files. … … 135 136 AC_SUBST([FCGI_CPPFLAGS]) 136 137 AC_SUBST([FCGI_LDFLAGS]) 138 139 140 # =========================================================================== 141 # Detect if json-c is available 142 # =========================================================================== 143 144 AC_CHECK_LIB([json-c], [main]) 145 JSON_LDFLAGS=`pkg-config --libs json-c` 146 JSON_CPPFLAGS=`pkg-config --cflags json-c` 147 148 AC_SUBST([JSON_LDFLAGS]) 149 AC_SUBST([JSON_CPPFLAGS]) 150 151 152 153 154 # =========================================================================== 155 # Detect if librabbitmq is available 156 # =========================================================================== 157 158 159 AC_CHECK_LIB([rabbitmq], [main]) 160 RABBITMQ_LDFLAGS=`pkg-config --libs librabbitmq` 161 RABBITMQ_CPPFLAGS=`pkg-config --cflags librabbitmq` 162 163 AC_SUBST([RABBITMQ_LDFLAGS]) 164 AC_SUBST([RABBITMQ_CPPFLAGS]) 165 166 # =========================================================================== 167 # Detect if libmysql is available 168 # =========================================================================== 169 170 171 AC_CHECK_LIB([mysqlclient], [main]) 172 MYSQL_LDFLAGS=`mysql_config --libs` 173 MYSQL_CPPFLAGS=`mysql_config --cflags` 174 175 AC_SUBST([MYSQL_LDFLAGS]) 176 AC_SUBST([MYSQL_CPPFLAGS]) 177 178 137 179 138 180 # =========================================================================== -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/main.cfg
r553 r617 1 1 [server] 2 req_worker=1 03 async_worker=1 02 req_worker=1 3 async_worker=1 4 4 max_requests=200 5 5 listen=/tmp/zoo.sock … … 10 10 uid=65534 11 11 gid=65534 12 #rootDir=/var/www/zoo-wps/cgi-bin 12 rootDir=/var/www/zoo-wps/cgi-bin 13 14 [rabbitmq] 15 host=192.168.1.167 16 port=5672 17 user=david 18 passwd=pass 19 exchange=amq.direct 20 routingkey=zoo 21 queue=zoo_service_queue 22 23 24 [status] 25 driver=mysql 26 user=david 27 passwd=pass 28 bdd=zoo_status 29 host=127.0.0.1 30 port=3306 13 31 14 32 [headers] -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal.c
r549 r617 1977 1977 xmlDocSetRootElement (doc, nr); 1978 1978 1979 if (hasStoredExecuteResponse == true) 1980 { 1979 1980 map * background = NULL; 1981 background = getMapFromMaps(m,"lenv","background"); 1982 1983 if (background != NULL){ 1984 /* requete asynchrone */ 1981 1985 /* We need to write the ExecuteResponse Document somewhere */ 1982 1986 FILE *output = fopen (stored_path, "w"); … … 2006 2010 fclose (output); 2007 2011 } 2012 else { 2008 2013 printDocument (m, doc, pid,out); 2009 2014 } 2010 2015 xmlCleanupParser (); 2011 2016 zooXmlCleanupNs (); … … 2031 2036 */ 2032 2037 xmlDocDumpFormatMemoryEnc (doc, &xmlbuff, &buffersize, encoding, 1); 2033 FCGX_FPrintF(out,(char *)xmlbuff); 2034 FCGX_FFlush(out); 2038 2039 2040 if (out != NULL){ 2041 FCGX_FPrintF(out,(char *)xmlbuff); 2042 FCGX_FFlush(out); 2043 } 2035 2044 //printf ("%s", xmlbuff); 2036 2045 //fflush (stdout); … … 3687 3696 if (fsize == 0) 3688 3697 { 3698 3689 3699 return errorException (*m, _("Unable to download the file."), 3690 3700 "InternalError", NULL,NULL); … … 3699 3709 free (tmpMap->value); 3700 3710 tmpMap->value = (char *) malloc ((fsize + 1) * sizeof (char)); 3701 if (tmpMap->value == NULL) 3711 if (tmpMap->value == NULL){ 3712 3702 3713 return errorException (*m, _("Unable to allocate memory."), 3703 3714 "InternalError", NULL,NULL); 3715 } 3704 3716 memcpy (tmpMap->value, fcontent, (fsize + 1) * sizeof (char)); 3705 3717 -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.c
r606 r617 1 /** 2 * Author : David Saggiorato 3 * 4 * Copyright 2008-2009 GeoLabs SARL. All rights reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 1 26 #include <string.h> 2 27 #include <stdio.h> -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.h
r606 r617 1 /** 2 * Author : David Saggiorato 3 * 4 * Copyright 2008-2009 GeoLabs SARL. All rights reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 1 26 #ifndef ZOO_JSON_H 2 27 #define ZOO_JSON_H 1 -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_loader.c
r553 r617 67 67 68 68 #include "service_zcfg.h" 69 #include "zoo_json.h" 70 #include "zoo_amqp.h" 71 #include "zoo_sql.h" 69 72 //#include "service_internal.h" 73 74 75 void 76 loadServiceAndRun (maps ** myMap, service * s1, map * request_inputs, 77 maps ** inputs, maps ** ioutputs, int *eres,FCGX_Stream *out, FCGX_Stream *err); 70 78 71 79 xmlXPathObjectPtr extractFromDoc (xmlDocPtr, const char *); … … 100 108 int pid = getpid(); 101 109 struct cgi_env *cgi; 102 //PrintEnv(request.err, "Request environment", request.envp);103 110 cgi = (struct cgi_env*)malloc(sizeof(struct cgi_env)); 104 111 cgiMain_init (NULL, NULL,&cgi,request); … … 455 462 if (strQuery != NULL) 456 463 free (strQuery); 457 464 /* 465 json_object *obj; 466 maptojson(&obj,tmpMap); 467 fprintf(stderr,"%s\n",json_object_to_json_string(obj)); 468 fflush(stderr); 469 */ 458 470 runRequest (&tmpMap,&cgi,request); 459 471 … … 525 537 return 1; 526 538 } 527 539 /* 540 json_object *jobj; 541 mapstojson(&jobj,conf); 542 fprintf (stderr,"The json object created: %s\n",json_object_to_json_string(jobj)); 543 freeMaps(&conf); 544 545 maps *conf_tmp; 546 jsontomaps(jobj,&conf_tmp); 547 dumpMaps(conf_tmp); 548 return 1; 549 */ 528 550 char *rootDir; 529 551 map *m_rootDir = getMapFromMaps (conf, "server", "rootDir"); … … 684 706 } 685 707 } 708 709 710 char * amqp_host; 711 map * m_amqp_host = getMapFromMaps (conf, "rabbitmq", "host"); 712 if (m_amqp_host == NULL){ 713 fprintf(stderr,"Configuration error: [rabbitmq] host"); 714 return 2; 715 } 716 else { 717 amqp_host = (char *)malloc((strlen(m_amqp_host->value) +1)*sizeof(char*)); 718 strncpy(amqp_host,m_amqp_host->value,strlen(m_amqp_host->value)); 719 amqp_host[strlen(m_amqp_host->value)] = '\0'; 720 } 721 722 int amqp_port; 723 map *m_amqp_port = getMapFromMaps (conf, "rabbitmq", "port"); 724 if (m_amqp_port == NULL){ 725 fprintf(stderr,"Configuration error: [rabbitmq] port"); 726 return 2; 727 } 728 else { 729 amqp_port = atoi(m_amqp_port->value); 730 if (amqp_port == 0){ 731 fprintf(stderr,"Configuration error: [rabbitmq] port"); 732 return 2; 733 } 734 } 735 736 char * amqp_user; 737 map * m_amqp_user = getMapFromMaps (conf, "rabbitmq", "user"); 738 if (m_amqp_user == NULL){ 739 fprintf(stderr,"Configuration error: [rabbitmq] user"); 740 return 2; 741 } 742 else { 743 amqp_user = (char *)malloc((strlen(m_amqp_user->value) +1)*sizeof(char*)); 744 strncpy(amqp_user,m_amqp_user->value,strlen(m_amqp_user->value)); 745 amqp_user[strlen(m_amqp_user->value)] = '\0'; 746 } 747 748 char * amqp_passwd; 749 map * m_amqp_passwd = getMapFromMaps (conf, "rabbitmq", "passwd"); 750 if (m_amqp_passwd == NULL){ 751 fprintf(stderr,"Configuration error: [rabbitmq] passwd"); 752 return 2; 753 } 754 else { 755 amqp_passwd = (char *)malloc((strlen(m_amqp_passwd->value) +1)*sizeof(char*)); 756 strncpy(amqp_passwd,m_amqp_passwd->value,strlen(m_amqp_passwd->value)); 757 amqp_passwd[strlen(m_amqp_passwd->value)] = '\0'; 758 } 759 760 char * amqp_exchange; 761 map * m_amqp_exchange = getMapFromMaps (conf, "rabbitmq", "exchange"); 762 if (m_amqp_exchange == NULL){ 763 fprintf(stderr,"Configuration error: [rabbitmq] exchange"); 764 return 2; 765 } 766 else { 767 amqp_exchange = (char *)malloc((strlen(m_amqp_exchange->value) +1)*sizeof(char*)); 768 strncpy(amqp_exchange,m_amqp_exchange->value,strlen(m_amqp_exchange->value)); 769 amqp_exchange[strlen(m_amqp_exchange->value)] = '\0'; 770 } 771 772 char * amqp_routingkey; 773 map * m_amqp_routingkey = getMapFromMaps (conf, "rabbitmq", "routingkey"); 774 if (m_amqp_routingkey == NULL){ 775 fprintf(stderr,"Configuration error: [amqp] routingkey"); 776 return 2; 777 } 778 else { 779 amqp_routingkey = (char *)malloc((strlen(m_amqp_routingkey->value) +1)*sizeof(char*)); 780 strncpy(amqp_routingkey,m_amqp_routingkey->value,strlen(m_amqp_routingkey->value)); 781 amqp_routingkey[strlen(m_amqp_routingkey->value)] = '\0'; 782 } 783 784 char * amqp_queue; 785 map * m_amqp_queue = getMapFromMaps (conf, "rabbitmq", "queue"); 786 if (m_amqp_queue == NULL){ 787 fprintf(stderr,"Configuration error: [rabbitmq] queue"); 788 return 2; 789 } 790 else { 791 amqp_queue = (char *)malloc((strlen(m_amqp_queue->value) +1)*sizeof(char*)); 792 strncpy(amqp_queue,m_amqp_queue->value,strlen(m_amqp_queue->value)); 793 amqp_queue[strlen(m_amqp_queue->value)] = '\0'; 794 } 795 796 char * status_user; 797 map * m_status_user = getMapFromMaps (conf, "status", "user"); 798 if (m_status_user == NULL){ 799 fprintf(stderr,"Configuration error: [status] user"); 800 return 2; 801 } 802 else { 803 status_user = (char *)malloc((strlen(m_status_user->value) +1)*sizeof(char*)); 804 strncpy(status_user,m_status_user->value,strlen(m_status_user->value)); 805 status_user[strlen(m_status_user->value)] = '\0'; 806 } 807 808 809 char * status_passwd; 810 map * m_status_passwd = getMapFromMaps (conf, "status", "passwd"); 811 if (m_status_passwd == NULL){ 812 fprintf(stderr,"Configuration error: [status] passwd"); 813 return 2; 814 } 815 else { 816 status_passwd = (char *)malloc((strlen(m_status_passwd->value) +1)*sizeof(char*)); 817 strncpy(status_passwd,m_status_passwd->value,strlen(m_status_passwd->value)); 818 status_passwd[strlen(m_status_passwd->value)] = '\0'; 819 } 820 821 char * status_bdd; 822 map * m_status_bdd = getMapFromMaps (conf, "status", "bdd"); 823 if (m_status_bdd == NULL){ 824 fprintf(stderr,"Configuration error: [status] bdd"); 825 return 2; 826 } 827 else { 828 status_bdd = (char *)malloc((strlen(m_status_bdd->value) +1)*sizeof(char*)); 829 strncpy(status_bdd,m_status_bdd->value,strlen(m_status_bdd->value)); 830 status_bdd[strlen(m_status_bdd->value)] = '\0'; 831 } 832 833 char * status_host; 834 map * m_status_host = getMapFromMaps (conf, "status", "host"); 835 if (m_status_host == NULL){ 836 fprintf(stderr,"Configuration error: [status] host"); 837 return 2; 838 } 839 else { 840 status_host = (char *)malloc((strlen(m_status_host->value) +1)*sizeof(char*)); 841 strncpy(status_host,m_status_host->value,strlen(m_status_host->value)); 842 status_host[strlen(m_status_host->value)] = '\0'; 843 } 844 845 int status_port; 846 map *m_status_port = getMapFromMaps (conf, "status", "port"); 847 if (m_status_port == NULL){ 848 fprintf(stderr,"Configuration error: [status] port"); 849 return 2; 850 } 851 else { 852 status_port = atoi(m_status_port->value); 853 if (status_port == 0){ 854 fprintf(stderr,"Configuration error: [status] port"); 855 return 2; 856 } 857 } 858 init_sql(status_host,status_user,status_passwd,status_bdd,status_port); 686 859 687 860 int sock = FCGX_OpenSocket(listen, listen_queue); … … 705 878 return 3; 706 879 } 707 880 881 init_amqp(amqp_host,amqp_port,amqp_user, amqp_passwd, amqp_exchange, amqp_routingkey,amqp_queue); 882 883 708 884 int fork_status = fork(); 709 885 if (fork_status == 0){ 710 886 //child 711 int forker_pid = getpid(); 887 int master_sync= getpid(); 888 fprintf(stderr,"Master sync%d\n",getpid()); 712 889 FCGX_Init(); 713 890 FCGX_Request request; … … 718 895 fork_status = fork(); 719 896 if (fork_status == 0){ 720 fprintf(stderr,"child %d \n",i);897 fprintf(stderr,"child sync %d \n",getpid()); 721 898 fflush(stderr); 722 899 break; … … 724 901 } 725 902 while(1){ 726 if (forker_pid != getpid()){ 903 /* mode synchrone */ 904 if (master_sync != getpid()){ 727 905 while(FCGX_Accept_r(&request) == 0){ 728 906 process(&request); … … 737 915 else { 738 916 wait(0); 739 fprintf(stderr,"new child\n"); 917 fprintf(stderr,"Master sync %d\n",getpid()); 918 fprintf(stderr,"New sync Child\n"); 740 919 fflush(stderr); 741 920 fork(); … … 744 923 } 745 924 else { 746 747 while(1); 925 int master_async = getpid(); 926 fprintf(stderr,"Master async %d\n",master_async); 927 int fork_s; 928 int j; 929 for (j = 0; j< async_worker; j++){ 930 fork_s = fork(); 931 if (fork_s == 0){ 932 fprintf(stderr,"child async %d \n",getpid()); 933 fflush(stderr); 934 break; 935 } 936 } 937 json_object *msg_obj; 938 json_object *maps_obj; 939 maps * map_c; 940 json_object *req_format_jobj; 941 maps * request_input_real_format; 942 json_object *req_jobj; 943 map * request_inputs; 944 json_object *outputs_jobj; 945 maps * request_output_real_format; 946 947 char *msg; 948 int c; 949 int eres; 950 char * service_identifier; 951 service * s1 = NULL; 952 while(1){ 953 /* mode asynchrone */ 954 if( master_async != getpid()){ 955 /*traitement des requetes de la queue */ 956 bind_amqp(); 957 init_consumer(); 958 while(1){ 959 960 c = consumer_amqp(&msg); 961 if (c == 0) 962 break; 963 msg_obj = json_tokener_parse(msg); 964 965 free(msg); 966 maps_obj = json_object_object_get(msg_obj,"maps"); 967 968 map_c = jsontomaps(maps_obj); 969 970 req_format_jobj = json_object_object_get(msg_obj,"request_input_real_format"); 971 request_input_real_format = jsontomaps(req_format_jobj); 972 973 req_jobj = json_object_object_get(msg_obj,"request_inputs"); 974 request_inputs = jsontomap(req_jobj); 975 976 outputs_jobj = json_object_object_get(msg_obj,"request_output_real_format"); 977 request_output_real_format = jsontomaps(outputs_jobj); 978 979 json_object_put(msg_obj); 980 981 /* traitemement du message */ 982 /* Recherche des references */ 983 maps* tmp=request_input_real_format; 984 HINTERNET hInternet = InternetOpen ((LPCTSTR) "ZooWPSClient\0",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); 985 while(tmp!=NULL){ 986 map * tmp_map = getMap(tmp->content,"xlink:href"); 987 if (tmp_map != NULL){ 988 if (loadRemoteFile(&map_c, &tmp_map, &hInternet,tmp_map->value) < 0) { 989 /* passer le status failed dans la base de donnée */ 990 fprintf(stderr,"Erreur de chargement \n"); 991 } 992 } 993 tmp=tmp->next; 994 } 995 runHttpRequests (&map_c, &request_input_real_format, &hInternet); 996 InternetCloseHandle (&hInternet); 997 free(tmp); 998 map * uuid = getMapFromMaps(map_c,"lenv","usid"); 999 if (uuid != NULL) 1000 start_job(uuid->value); 1001 map *t=createMap("background","1"); 1002 maps * lenv = getMaps(map_c,"lenv"); 1003 addMapToMap(&lenv->content,t); 1004 freeMap(&t); 1005 free(t); 1006 1007 map * m_identifier = getMap (request_inputs, "Identifier"); 1008 1009 service_identifier = zStrdup (m_identifier->value); 1010 1011 s1 = search_service (service_identifier); 1012 free(service_identifier); 1013 1014 1015 //dumpMaps(request_input_real_format); 1016 1017 loadServiceAndRun(&map_c, s1,request_inputs,&request_input_real_format, &request_output_real_format, &eres,NULL,NULL); 1018 if (eres == SERVICE_SUCCEEDED) { 1019 outputResponse (s1,request_input_real_format,request_output_real_format,request_inputs, 0, map_c, eres,NULL,NULL); 1020 } 1021 1022 1023 //dumpMaps(request_output_real_format); 1024 //fprintf(stderr,"################################################################\n"); 1025 //dumpMaps(map_c); 1026 1027 outputResponse (s1,request_input_real_format,request_output_real_format,request_inputs, 0, map_c, eres,NULL,NULL); 1028 1029 1030 freeMaps(&map_c); 1031 map_c= NULL; 1032 1033 freeMaps(&request_input_real_format); 1034 request_input_real_format = NULL; 1035 1036 //dumpMap(request_inputs); 1037 freeMap(&request_inputs); 1038 request_inputs = NULL; 1039 1040 //dumpMaps(request_output_real_format); 1041 freeMaps(&request_output_real_format); 1042 request_output_real_format = NULL; 1043 consumer_ack_amqp(c); 1044 1045 1046 } 1047 close_amqp(); 1048 1049 1050 1051 1052 1053 } 1054 else { 1055 wait(0); 1056 fprintf(stderr,"Master async %d\n",getpid()); 1057 fprintf(stderr,"New async Child\n"); 1058 fflush(stderr); 1059 fork(); 1060 } 1061 } 748 1062 749 1063 } -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c
r604 r617 31 31 #include "zoo_amqp.h" 32 32 #include "zoo_sql.h" 33 #include "zoo_json.h" 33 34 extern "C" 34 35 { … … 275 276 } 276 277 277 #include "zoo_json.h"278 278 void 279 279 loadServiceAndRun (maps ** myMap, service * s1, map * request_inputs, … … 281 281 { 282 282 283 json_object *obj;284 mapstojson(&obj,*myMap);285 fprintf(stderr,"myMaps: %s\n",json_object_to_json_string(obj));286 287 288 json_object *obj3;289 mapstojson(&obj3,*inputs);290 fprintf(stderr,"inputs: %s\n",json_object_to_json_string(obj3));291 292 293 json_object *obj1;294 maptojson(&obj1,request_inputs);295 fprintf(stderr,"request_inputs: %s\n",json_object_to_json_string(obj1));296 297 json_object *obj2;298 mapstojson(&obj2,*ioutputs);299 fprintf(stderr,"ioutputs: %s\n",json_object_to_json_string(obj2));300 301 302 303 fflush(stderr);304 305 283 306 284 char tmps1[1024]; … … 309 287 maps *request_output_real_format = *ioutputs; 310 288 maps *request_input_real_format = *inputs; 289 map * background = NULL; 290 map * uuid = getMapFromMaps(m,"lenv","usid"); 291 background = getMapFromMaps(m,"lenv","background"); 292 293 311 294 /** 312 295 * Extract serviceType to know what kind of service should be loaded … … 443 426 ("Error occured while running the %s function: %s"), 444 427 s1->name, errstr); 445 errorException (m, tmpMsg, "InternalError", NULL,out); 428 429 if (background == NULL){ 430 errorException (m, tmpMsg, "InternalError", NULL,out); 431 } 432 else { 433 /* mise a jour de la table status */ 434 } 446 435 free (tmpMsg); 447 436 #ifdef DEBUG … … 466 455 fflush (stderr); 467 456 #endif 468 *eres = 457 458 *eres = 469 459 execute (&m, &request_input_real_format, 470 460 &request_output_real_format); 471 461 #ifdef DEBUG 472 fprintf (stderr, "Function loaded and returned %d\n", eres);462 fprintf (stderr, "Function loaded and returned %d\n", *eres); 473 463 fflush (stderr); 474 464 #endif … … 497 487 sprintf (tmps, _("C Library can't be loaded %s"), errstr); 498 488 map *tmps1 = createMap ("text", tmps); 499 printExceptionReportResponse (m, tmps1,out); 489 if (background == NULL){ 490 printExceptionReportResponse (m, tmps1,out); 491 } 492 else { 493 /* mise a jour table status */ 494 } 500 495 *eres = -1; 501 496 freeMap (&tmps1); … … 578 573 ("Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n"), 579 574 r_inputs->value); 580 map *tmps = createMap ("text", tmpv); 581 printExceptionReportResponse (m, tmps,out); 575 if (background == NULL){ 576 map *tmps = createMap ("text", tmpv); 577 printExceptionReportResponse (m, tmps,out); 578 } 579 else { 580 /* mise jour table status */ 581 } 582 582 *eres = -1; 583 583 } … … 3043 3043 if (status == NULLMAP) 3044 3044 { 3045 3045 3046 loadServiceAndRun 3046 3047 (&m, s1, … … 3055 3056 3056 3057 eres = SERVICE_ACCEPTED; 3057 json_object * msg_jobj = json_object_new_object(); 3058 json_object_object_add(msg_jobj,"service_identifier",json_object_new_string(service_identifier)); 3059 3060 3058 json_object *msg_jobj = json_object_new_object(); 3061 3059 json_object *maps_obj; 3062 3060 mapstojson(&maps_obj,m); … … 3076 3074 mapstojson(&outputs_jobj,request_output_real_format); 3077 3075 json_object_object_add(msg_jobj,"request_output_real_format",outputs_jobj); 3078 3079 if ( (send_msg(json_object_to_json_string(msg_jobj),"application/json") != 0) || (add_status(uuid) != 0) ){ 3076 3077 bind_amqp(); 3078 3079 if ( (send_msg(json_object_to_json_string(msg_jobj),"application/json") != 0) || (add_job(uuid) != 0) ){ 3080 3080 eres = SERVICE_FAILED; 3081 3081 } 3082 close_amqp(); 3083 json_object_put(msg_jobj); 3084 3082 3085 3083 3086 } -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_sql.c
r603 r617 1 /** 2 * Author : David Saggiorato 3 * 4 * Copyright 2008-2009 GeoLabs SARL. All rights reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 26 1 27 #include <string.h> 2 28 #include <stdio.h> … … 58 84 } 59 85 60 int add_ status(const char * uuid) {86 int add_job(const char * uuid) { 61 87 init_connection(); 62 88 const char * query = "insert into status (uuid,status,created_time) values ('%s','queue',now())"; … … 72 98 return 0; 73 99 } 100 101 int start_job(const char *uuid){ 102 init_connection(); 103 const char * query = "update status set start_date=now(), status='running', progress=0 where uuid='%s';"; 104 char * query_f = (char*) malloc(strlen(query) + strlen(uuid) + 1); 105 sprintf(query_f,query,uuid); 106 if (mysql_query(con, query_f) != 0){ 107 fprintf(stderr, "%s\n", mysql_error(con)); 108 free(query_f); 109 return -1; 110 } 111 free(query_f); 112 mysql_close(con); 113 return 0; 114 } 115 116 -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_sql.h
r603 r617 1 /** 2 * Author : David Saggiorato 3 * 4 * Copyright 2008-2009 GeoLabs SARL. All rights reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 26 1 27 #ifndef ZOO_SQL_H 2 28 #define ZOO_SQL_H 1 … … 5 31 void init_sql(const char* host,const char *user, const char *passwd, const char * bdd,int port); 6 32 char * get_uuid(); 7 int add_status(const char * uuid); 33 int add_job(const char * uuid); 34 int start_job(const char *uuid); 35 8 36 #endif
Note: See TracChangeset
for help on using the changeset viewer.