Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SharpAI Private Deployment #1

Open
Sunny-wong opened this Issue Mar 7, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@Sunny-wong
Copy link
Collaborator

Sunny-wong commented Mar 7, 2019

1 mongodb

1.1 Start mongodb without password
$ mkdir /root/mongodb0830/db

$ docker run -d --log-opt max-size=50m \
    -v /root/mongodb0830/db:/data/db \
    -p 27017:27017 mongo:3.2 --smallfiles --dbpath /data/db --replSet workaioplog
1.2 Init database, create cluster/roles
$ mongo
> use admin
switched to db admin
> config={_id: "workaioplog", members:[{_id:0, host:"aidb.tiegushi.com"}]} # local ip
{
        "_id" : "workai",
        "members" : [
                {
                        "_id" : 0,
                        "host" : "127.0.0.1"
                }
        ]
}
>  rs.initiate(config)
{ "ok" : 1 }

workai:OTHER>  use admin
switched to db admin
workai:PRIMARY> db.createUser({user:"admin",pwd:"admin",roles:["root"]})
Successfully added user: { "user" : "admin", "roles" : [ "root" ] }
workai:PRIMARY> db.auth("admin","admin")
1
workai:PRIMARY> use workai
switched to db workai
workai:PRIMARY> db.createUser({user:"workAIAdmin", pwd:"workAIAdmin",roles:[{role:"readWrite",db:"workai"}]})
Successfully added user: {
        "user" : "workAIAdmin",
        "roles" : [
                {
                        "role" : "readWrite",
                        "db" : "workai"
                }
        ]
}
workai:PRIMARY> db.auth("workAIAdmin","workAIAdmin")
1

workai:OTHER>  use admin
workai:PRIMARY> db.createUser({user:"oplogger",pwd:"oplogger", "roles" : [ "root" ]})
1.3 Stop docker,start mongodb with password
sudo docker run -d --log-opt max-size=50m \
    -v /root/mongodb0830/db:/data/db \
    -p 27017:27017 mongo:3.2 --smallfiles --dbpath /data/db --replSet workaioplog --auth

2 hotShareWeb

https://github.com/SharpAI/mobile_app_server/tree/sharpai/hotShareWeb

# hotShare/hotShareWeb/lib/mqtt_mq_server.js
# mqtt_connection=mqtt.connect('mqtt://192.168.31.106:8080',mqttOptions); # change to local ip

$ ./build_bundle.sh  # hotShare/hotShareWeb/build_bundle.sh
$ docker build -t lambdazhang/raidcdn:sharpai-1.0.21 .

docker run --name sharp-AI-official-IMG \
-p 80:80 \
-v /etc/localtime:/etc/localtime:ro \
-e CLUSTER_WORKERS_COUNT=2 \
-e DDP_ALTER_URL=ws://192.168.31.106/websocket \
-e VIRTUAL_HOST=192.168.31.106,192.168.31.106 \
-e SERVER_DOMAIN_NAME=192.168.31.106 \
-e ROOT_URL=http://192.168.31.106 \
-e DDP_DEFAULT_CONNECTION_URL=http://192.168.31.106 \
-e MONGO_URL=mongodb://workAIAdmin:workAIAdmin@192.168.31.106:27017/workai?replicaSet=workaioplog\&readPreference=primaryPreferred\&connectTimeoutMS=30000\&socketTimeoutMS=30000\&poolSize=20 \
-e MONGO_OPLOG_URL=mongodb://oplogger:oplogger@192.168.31.106:27017/local?replicaSet=workaioplog\&authSource=admin\&readPreference=primaryPreferred\&connectTimeoutMS=60000\&socketTimeoutMS=30000\&poolSize=20 \
-e MAIL_URL=smtp://postmaster%40tiegushi.com:a7e104e236965118d8f1bd3268f36d8c@smtp.mailgun.org:587/ \
-e ALIYUN_ACCESS_KEY_ID=Vh0snNA4Orv3emBj \
-e ALIYUN_ACCESS_KEY_SECRET=d7p2eNO8GuMl1GtIZ0at4wPDyED4Nz \
--log-opt max-size=500m \
-d lambdazhang/raidcdn:sharpai-1.0.21

3 mqtt

https://github.com/emqx/emqx/releases/download/v3.0.1/emqx-docker-v3.0.1-amd64.zip

$ docker load -i emqx-docker-v3.0.1-amd64
$ docker run -d --restart=always --name emq -p 81:8083 -p 8080:1883 -p 18083:18083 -e EMQ_MQTT__MQUEUE__MAX_LENGTH=2000 -e EMQ_MQTT__SESSION__EXPIRY_INTERVAL=3d emqx/emqx:v3.0.1-amd64

4 mqtt -> push notification

https://github.com/SharpAI/mobile_app_server/tree/sharpai/mqtt-pushnotification

$ docker build -t lambdazhang/raidcdn:workai-mq-push-1.7.0 .
$ docker run --log-opt max-size=50m \
-e SERVICE_NAME=MQTT_Notification_Woekai \
-e PRODUCTION=true \
-e SERVICE_INDEX=0 \
-e DEBUG_MESSAGE=1 \
-e ALLOW_GROUP_NOTIFICATION=1 \
-e SERVER_URL=http://192.168.31.106/ \
-e REDIS_PASSWORD='87302aKecatcp' \
-e REDIS_HOST='192.168.31.106' \
-e MQTT_URL='ws://192.168.31.106:80' \
-e MONGO_URL=mongodb://workAIAdmin:workAIAdmin@192.168.31.106:27017/workai?replicaSet=workaioplog\&readPreference=primaryPreferred\&connectTimeoutMS=30000\&socketTimeoutMS=30000\&poolSize=20 \
--restart=always --name='workai_mq_push'  lambdazhang/raidcdn:workai-mq-push-1.7.0

5 Push Notification

https://github.com/SharpAI/mobile_app_server/tree/sharpai/hotSharePush

$ docker build -t lambdazhang/raidcdn:workaipushnotification1.2.0 .
$ docker run -d --log-opt max-size=50m \
-e SERVICE_NAME='workaiPushServer' \
-e PRODUCTION=true \
-e SERVICE_INDEX=0 \
-e VIRTUAL_HOST=192.168.31.106 \
-e MONGO_URL=mongodb://workAIAdmin:workAIAdmin@192.168.31.106:27017/workai?replicaSet=workaioplog\&readPreference=primaryPreferred\&connectTimeoutMS=30000\&socketTimeoutMS=30000\&poolSize=20 \
-e MONGO_OPLOG=mongodb://oplogger:oplogger@192.168.31.106:27017/local?authSource=admin \
-d lambdazhang/raidcdn:workaipushnotification1.2.0

3288 change hosts

192.168.31.106 workaihost.tiegushi.com
192.168.31.106 mq.tiegushi.com

@solderzzc solderzzc changed the title sharpai 本地部署文档 SharpAI Private Deployment Mar 7, 2019

@cici-tan

This comment has been minimized.

Copy link
Contributor

cici-tan commented Mar 7, 2019

6 hotshare

https://github.com/SharpAI/mobile_app_server/tree/sharpai/hotShareMobile/build.sh

# meteor build ~/build-sharpai --server=http://192.168.31.106 # change to local ip

https://github.com/SharpAI/mobile_app_server/tree/sharpai/hotShareMobile/client/mqtt_mq_client.js

# - mqtt_connection=new Paho.MQTT.Client('mq.tiegushi.com', Number(80), clientId);
# + mqtt_connection=new Paho.MQTT.Client('192.168.31.106', Number(80), clientId); # change it to local ip for mqtt server

https://github.com/SharpAI/mobile_app_server/tree/sharpai/hotShareMobile/client/mqtt_mq_client_native.js

    var mqttOptions = {
      username:clientId,
      password:localStorage.getItem('Meteor.loginToken'),
-     host: 'mq.tiegushi.com',
+     host: '192.168.31.106', # change it to local ip for mqtt server
      port: 8080,
      timeout: 30,
      keepAlive:10,

https://github.com/SharpAI/mobile_app_server/tree/sharpai/hotShareMobile/client/registration/authOverlay/authOverlay.js

  //if (result.text.indexOf(requiredStr)=== 0) {
-   if (result.text.indexOf('http://workaicdn.tiegushi.com/simple-chat/to/group?id=') >= 0 || result.text.indexOf('http://testworkai.tiegushi.com/simple-chat/to/group?id=') >= 0){
+   if (true/*result.text.indexOf('http://workaicdn.tiegushi.com/simple-chat/to/group?id=') >= 0 || result.text.indexOf('http://testworkai.tiegushi.com/simple-chat/to/group?id=') >= 0*/){
    //var groupid = result.text.substring(requiredStr.length);
    var groupid = result.text.substr(result.text.lastIndexOf('?id=')+'?id='.length);

solderzzc added a commit that referenced this issue Mar 19, 2019

Remove unusing files to easy the development task.
Please check this file for local/cloud deployment:
#1
@xxt90n

This comment has been minimized.

Copy link

xxt90n commented Apr 3, 2019

Excuse me, this shell script, after coming down, how can I see a page file?

hotShareWeb/build_bundle.sh this file

@xxt90n

This comment has been minimized.

Copy link

xxt90n commented Apr 3, 2019

what's lambdazhang/raidcdn:sharpai-1.0.21, here's the error log on my side:

Unable to find image 'lambdazhang/raidcdn:sharpai-1.0.21' locally

@Sunny-wong

This comment has been minimized.

Copy link
Collaborator Author

Sunny-wong commented Apr 3, 2019

@xxt90n 'lambdazhang/raidcdn:sharpai-1.0.21' is a docker image
you need to run ./build_bundle.sh, then:

$ docker build -t lambdazhang/raidcdn:sharpai-1.0.21 .

@SharpAI SharpAI deleted a comment from xxt90n Apr 4, 2019

@SharpAI SharpAI deleted a comment from Sunny-wong Apr 4, 2019

@SharpAI SharpAI deleted a comment from xxt90n Apr 4, 2019

@SharpAI SharpAI deleted a comment from Sunny-wong Apr 4, 2019

@SharpAI SharpAI deleted a comment from xxt90n Apr 4, 2019

@SharpAI SharpAI locked as resolved and limited conversation to collaborators Apr 4, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.