-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6608 from RocketChat/feature/snap-oplog
[New] Switch Snaps to use oplog
- Loading branch information
Showing
7 changed files
with
63 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var ism = db.isMaster(); | ||
if (!ism.ismaster) { | ||
rs.initiate( | ||
{ | ||
_id: 'rs0', | ||
members: [ | ||
{ | ||
_id: 0, | ||
host: 'localhost:27017' | ||
} | ||
] | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
#!/bin/sh | ||
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 | ||
|
||
env LC_ALL=C mongod --bind_ip 127.0.0.1 --pidfilepath $SNAP_COMMON/mongod.pid --smallfiles --journal --dbpath=$SNAP_COMMON --replSet rs0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters