Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
4b72c561
Commit
4b72c561
authored
Mar 30, 2011
by
antirez
Browse files
fix to configuration saving on first start
parent
c7c7cfbd
Changes
1
Show whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
4b72c561
...
@@ -44,7 +44,7 @@ int clusterLoadConfig(char *filename) {
...
@@ -44,7 +44,7 @@ int clusterLoadConfig(char *filename) {
return
REDIS_OK
;
return
REDIS_OK
;
fmterr:
fmterr:
redisLog
(
REDIS_WARNING
,
"Unrecovarable error: corrupted cluster.conf file."
);
redisLog
(
REDIS_WARNING
,
"Unrecovarable error: corrupted
redis-
cluster.conf file."
);
fclose
(
fp
);
fclose
(
fp
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -69,6 +69,8 @@ err:
...
@@ -69,6 +69,8 @@ err:
}
}
void
clusterInit
(
void
)
{
void
clusterInit
(
void
)
{
int
saveconf
=
0
;
server
.
cluster
.
myself
=
createClusterNode
(
NULL
,
REDIS_NODE_MYSELF
);
server
.
cluster
.
myself
=
createClusterNode
(
NULL
,
REDIS_NODE_MYSELF
);
server
.
cluster
.
state
=
REDIS_CLUSTER_FAIL
;
server
.
cluster
.
state
=
REDIS_CLUSTER_FAIL
;
server
.
cluster
.
nodes
=
dictCreate
(
&
clusterNodesDictType
,
NULL
);
server
.
cluster
.
nodes
=
dictCreate
(
&
clusterNodesDictType
,
NULL
);
...
@@ -79,17 +81,20 @@ void clusterInit(void) {
...
@@ -79,17 +81,20 @@ void clusterInit(void) {
sizeof
(
server
.
cluster
.
importing_slots_from
));
sizeof
(
server
.
cluster
.
importing_slots_from
));
memset
(
server
.
cluster
.
slots
,
0
,
memset
(
server
.
cluster
.
slots
,
0
,
sizeof
(
server
.
cluster
.
slots
));
sizeof
(
server
.
cluster
.
slots
));
if
(
clusterLoadConfig
(
"cluster.conf"
)
==
REDIS_ERR
)
{
if
(
clusterLoadConfig
(
"
redis-
cluster.conf"
)
==
REDIS_ERR
)
{
/* No configuration found. We will just use the random name provided
/* No configuration found. We will just use the random name provided
* by the createClusterNode() function. */
* by the createClusterNode() function. */
redisLog
(
REDIS_NOTICE
,
"No cluster configuration found, I'm %.40s"
,
redisLog
(
REDIS_NOTICE
,
"No cluster configuration found, I'm %.40s"
,
server
.
cluster
.
myself
->
name
);
server
.
cluster
.
myself
->
name
);
if
(
clusterSaveConfig
(
"cluster.conf"
)
==
-
1
)
{
saveconf
=
1
;
}
clusterAddNode
(
server
.
cluster
.
myself
);
if
(
saveconf
)
{
if
(
clusterSaveConfig
(
"redis-cluster.conf"
)
==
-
1
)
{
redisLog
(
REDIS_WARNING
,
"Fatal: can't update cluster config file."
);
redisLog
(
REDIS_WARNING
,
"Fatal: can't update cluster config file."
);
exit
(
1
);
exit
(
1
);
}
}
}
}
clusterAddNode
(
server
.
cluster
.
myself
);
/* We need a listening TCP port for our cluster messaging needs */
/* We need a listening TCP port for our cluster messaging needs */
server
.
cfd
=
anetTcpServer
(
server
.
neterr
,
server
.
cfd
=
anetTcpServer
(
server
.
neterr
,
server
.
port
+
REDIS_CLUSTER_PORT_INCR
,
server
.
bindaddr
);
server
.
port
+
REDIS_CLUSTER_PORT_INCR
,
server
.
bindaddr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment