Addition of searching rules for the gateway.cnf file. Better diagnostics for missing
gatway.cnf file. Cleanup for config reading when no modules could be found.
This commit is contained in:
4
README
4
README
@ -52,5 +52,9 @@ modules it will search using a predescribed search path. The rules are:
|
|||||||
|
|
||||||
3. Look in /usr/local/skysql/gateway/modules
|
3. Look in /usr/local/skysql/gateway/modules
|
||||||
|
|
||||||
|
Configuration is read by default from the file $GATEWAY_HOME/etc/gateway.cnf,
|
||||||
|
/etc/gateway.cnf, an example file is included in the root of the source tree. The
|
||||||
|
default location can be overriden by use of the -c flag on the command line. This
|
||||||
|
should be immediately followed by the path to the configuration file.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -163,7 +163,7 @@ CONFIG_CONTEXT *obj;
|
|||||||
CONFIG_CONTEXT *obj1 = context;
|
CONFIG_CONTEXT *obj1 = context;
|
||||||
while (obj1)
|
while (obj1)
|
||||||
{
|
{
|
||||||
if (strcmp(s, obj1->object) == 0)
|
if (strcmp(s, obj1->object) == 0 && obj->element && obj1->element)
|
||||||
serviceAddBackend(obj->element, obj1->element);
|
serviceAddBackend(obj->element, obj1->element);
|
||||||
obj1 = obj1->next;
|
obj1 = obj1->next;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ CONFIG_CONTEXT *obj;
|
|||||||
CONFIG_CONTEXT *ptr = context;
|
CONFIG_CONTEXT *ptr = context;
|
||||||
while (ptr && strcmp(ptr->object, service) != 0)
|
while (ptr && strcmp(ptr->object, service) != 0)
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
if (ptr)
|
if (ptr && ptr->element)
|
||||||
serviceAddProtocol(ptr->element, protocol, atoi(port));
|
serviceAddProtocol(ptr->element, protocol, atoi(port));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gw.h>
|
#include <gw.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <service.h>
|
#include <service.h>
|
||||||
#include <server.h>
|
#include <server.h>
|
||||||
#include <dcb.h>
|
#include <dcb.h>
|
||||||
@ -170,7 +171,17 @@ main(int argc, char **argv)
|
|||||||
int daemon_mode = 1;
|
int daemon_mode = 1;
|
||||||
sigset_t sigset;
|
sigset_t sigset;
|
||||||
int n;
|
int n;
|
||||||
char *cnf_file = "/etc/gateway.cnf";
|
char buf[1024], *home, *cnf_file = NULL;
|
||||||
|
|
||||||
|
if ((home = getenv("GATEWAY_HOME")) != NULL)
|
||||||
|
{
|
||||||
|
sprintf(buf, "%s/etc/gateway.cnf", home);
|
||||||
|
if (access(buf, R_OK) == 0)
|
||||||
|
cnf_file = buf;
|
||||||
|
}
|
||||||
|
if (cnf_file == NULL && access("/etc/gateway.cnf", R_OK) == 0)
|
||||||
|
cnf_file = "/etc/gateway.cnf";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (n = 0; n < argc; n++)
|
for (n = 0; n < argc; n++)
|
||||||
@ -186,6 +197,13 @@ char *cnf_file = "/etc/gateway.cnf";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cnf_file == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unable to find a gateway configuration file, either install one in\n");
|
||||||
|
fprintf(stderr, "/etc/gateway.cnf, $GATEWAY_HOME/etc/gateway.cnf or use the -c option.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!load_config(cnf_file))
|
if (!load_config(cnf_file))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to load gateway configuration file %s\n", cnf_file);
|
fprintf(stderr, "Failed to load gateway configuration file %s\n", cnf_file);
|
||||||
|
|||||||
Reference in New Issue
Block a user