Skip to content
Snippets Groups Projects
Commit b3dcf1aa authored by Gabriel Engel's avatar Gabriel Engel Committed by GitHub
Browse files

Merge pull request #6608 from RocketChat/feature/snap-oplog

[New] Switch Snaps to use oplog
parents 2fa965cb f755848a
No related branches found
No related tags found
No related merge requests found
...@@ -13,11 +13,11 @@ description: Have your own Slack like online chat, built with Meteor. https://ro ...@@ -13,11 +13,11 @@ description: Have your own Slack like online chat, built with Meteor. https://ro
confinement: strict confinement: strict
apps: apps:
rocketchat-server: rocketchat-server:
command: env BABEL_CACHE_DIR=/tmp ROOT_URL=http://localhost PORT=3000 MONGO_URL=mongodb://localhost:27017/parties Accounts_AvatarStorePath=$SNAP_COMMON/uploads node $SNAP/main.js command: startRocketChat
daemon: simple daemon: simple
plugs: [network, network-bind] plugs: [network, network-bind]
rocketchat-mongo: rocketchat-mongo:
command: env LC_ALL=C mongod --bind_ip 127.0.0.1 --smallfiles --dbpath=$SNAP_COMMON command: startmongo
daemon: simple daemon: simple
plugs: [network, network-bind] plugs: [network, network-bind]
rocketchat-caddy: rocketchat-caddy:
...@@ -84,10 +84,10 @@ parts: ...@@ -84,10 +84,10 @@ parts:
organize: organize:
rcbackup: bin/rcbackup rcbackup: bin/rcbackup
startmongo: bin/startmongo startmongo: bin/startmongo
initmongo: bin/initmongo startRocketChat: bin/startRocketChat
initreplset.js: bin/initreplset.js
Caddyfile: bin/Caddyfile Caddyfile: bin/Caddyfile
initcaddy: bin/initcaddy initcaddy: bin/initcaddy
initmongoreplset.js: bin/initmongoreplset.js
snap: snap:
- bin - bin
caddy: caddy:
......
#!/bin/sh
echo "initializing replset if necessary... in 60 seconds"
sleep 60
echo "after 60 seconds, checking for replset..."
mongo $SNAP/bin/initmongoreplset.js
var ism = db.isMaster();
printjson(ism);
if (ism.ismaster) {
} else
{
var msg = rs.initiate();
printjson(msg);
}
var ism = db.isMaster();
if (!ism.ismaster) {
rs.initiate(
{
_id: 'rs0',
members: [
{
_id: 0,
host: 'localhost:27017'
}
]
});
}
#!/bin/bash
function start_rocketchat {
echo "Checking if oplog has been enabled, and enabling if not"
LC_ALL=C mongo $SNAP/bin/initreplset.js
export BABEL_CACHE_DIR=/tmp
export ROOT_URL=http://localhost
export PORT=3000
export MONGO_URL=mongodb://localhost:27017/parties
export MONGO_OPLOG_URL=mongodb://localhost:27017/local
export Accounts_AvatarStorePath=$SNAP_COMMON/uploads
node $SNAP/main.js
}
sleep_time=5
try_times=0
function try_start {
search=$(ps --pid $(cat $SNAP_COMMON/mongod.pid) -o comm=)
if [ $search ]
then
start_rocketchat
else
if [[ "$try_times" == 5 || "$try_times" > 5 ]]; then
echo "Was unable to connect to Mongo. Please make sure Mongo has started successfully: sudo systemctl status snap.rocketchat-server.rocketchat-mongo to view logs: sudo journalctl -u snap.rocketchat-server.rocketchat-mongo"
exit 1;
fi
((try_times += 1))
((sleep_time += 5))
echo "Mongo is not available, can't start. Waiting ${sleep_time} seconds and trying again"
sleep $sleep_time
try_start
fi
}
try_start
#!/bin/sh env LC_ALL=C mongod --bind_ip 127.0.0.1 --pidfilepath $SNAP_COMMON/mongod.pid --smallfiles --journal --dbpath=$SNAP_COMMON --replSet rs0
echo "initializing replset backgrounded..."
$SNAP/bin/initmongo &
echo "Starting mongodb server in replicaset standalone mode..."
mongod --bind_ip 127.0.0.1 --smallfiles --dbpath=$SNAP_COMMON --journal --replSet rcreplset
...@@ -13,11 +13,11 @@ description: Have your own Slack like online chat, built with Meteor. https://ro ...@@ -13,11 +13,11 @@ description: Have your own Slack like online chat, built with Meteor. https://ro
confinement: strict confinement: strict
apps: apps:
rocketchat-server: rocketchat-server:
command: env BABEL_CACHE_DIR=/tmp ROOT_URL=http://localhost PORT=3000 MONGO_URL=mongodb://localhost:27017/parties Accounts_AvatarStorePath=$SNAP_COMMON/uploads node $SNAP/main.js command: startRocketChat
daemon: simple daemon: simple
plugs: [network, network-bind] plugs: [network, network-bind]
rocketchat-mongo: rocketchat-mongo:
command: env LC_ALL=C mongod --bind_ip 127.0.0.1 --smallfiles --dbpath=$SNAP_COMMON command: startmongo
daemon: simple daemon: simple
plugs: [network, network-bind] plugs: [network, network-bind]
rocketchat-caddy: rocketchat-caddy:
...@@ -84,10 +84,10 @@ parts: ...@@ -84,10 +84,10 @@ parts:
organize: organize:
rcbackup: bin/rcbackup rcbackup: bin/rcbackup
startmongo: bin/startmongo startmongo: bin/startmongo
initmongo: bin/initmongo startRocketChat: bin/startRocketChat
initreplset.js: bin/initreplset.js
Caddyfile: bin/Caddyfile Caddyfile: bin/Caddyfile
initcaddy: bin/initcaddy initcaddy: bin/initcaddy
initmongoreplset.js: bin/initmongoreplset.js
snap: snap:
- bin - bin
caddy: caddy:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment