This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new f25b6e0 add mongo init script (#851)
f25b6e0 is described below
commit f25b6e03d1fbbba2f6966128645c4b6004c7b468
Author: panqian <[email protected]>
AuthorDate: Mon Feb 8 16:23:45 2021 +0800
add mongo init script (#851)
---
datasource/mongo/client/mongo.go | 1 +
deployments/db.js | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/datasource/mongo/client/mongo.go b/datasource/mongo/client/mongo.go
index f63c6a9..8f23eee 100644
--- a/datasource/mongo/client/mongo.go
+++ b/datasource/mongo/client/mongo.go
@@ -128,6 +128,7 @@ func (mc *MongoClient) newClient(ctx context.Context) (err
error) {
clientOptions := options.Client().ApplyURI(mc.dbconfig.URI)
mc.client, err = mongo.Connect(ctx, clientOptions)
if err != nil {
+ log.Error("failed to connect to mongo", err)
if derr := mc.client.Disconnect(ctx); derr != nil {
log.Error("[init mongo client] failed to disconnect
mongo clients", derr)
}
diff --git a/deployments/db.js b/deployments/db.js
new file mode 100644
index 0000000..53b97e4
--- /dev/null
+++ b/deployments/db.js
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+db.createUser(
+ {
+ user: "sc",
+ pwd: "123",
+ roles:[
+ {
+ role: "readWrite",
+ db: "servicecenter"
+ }
+ ]
+ }
+);