| 1 |
require 'strict'.on() |
| 2 |
fiber = require 'fiber' |
| 3 |
|
| 4 |
local instance_id = string.match(arg[1], '^%d+$') |
| 5 |
assert(instance_id, 'malformed instance id') |
| 6 |
|
| 7 |
local port = 3300 + instance_id |
| 8 |
local workdir = 'ha_tnt'..instance_id |
| 9 |
|
| 10 |
box.cfg{ |
| 11 |
listen = '0.0.0.0:'..port, |
| 12 |
wal_dir = workdir, |
| 13 |
memtx_dir = workdir, |
| 14 |
readahead = 10 * 1024 * 1024, -- to keep up with benchmark load. |
| 15 |
net_msg_max = 1024, -- to keep up with benchmark load. |
| 16 |
|
| 17 |
instance_uuid='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa'..instance_id, |
| 18 |
|
| 19 |
replication = { |
| 20 |
'tnt1:'..3301, |
| 21 |
'tnt2:'..3302, |
| 22 |
'tnt3:'..3303, |
| 23 |
}, |
| 24 |
replication_connect_quorum=0, |
| 25 |
|
| 26 |
-- The instance is set to candidate, so it may become leader itself |
| 27 |
-- as well as vote for other instances. |
| 28 |
-- |
| 29 |
-- Alternative: set one of the three instances to `voter`, so that it |
| 30 |
-- never becomes a leader but still votes for one of its peers and helps |
| 31 |
-- it reach election quorum (2 in our case). |
| 32 |
election_mode='candidate', |
| 33 |
-- Quorum for both synchronous transactions and |
| 34 |
-- leader election votes. |
| 35 |
replication_synchro_quorum=2, |
| 36 |
-- Synchronous replication timeout. The transaction will be |
| 37 |
-- rolled back if no quorum is achieved during 1 second. |
| 38 |
replication_synchro_timeout=1, |
| 39 |
-- Heartbeat timeout. A leader is considered dead if it doesn't |
| 40 |
-- send heartbeats for 4 * replication_timeout (1 second in our case). |
| 41 |
-- Once the leader is dead, remaining instances start a new election round. |
| 42 |
replication_timeout=0.25, |
| 43 |
-- Timeout between elections. Needed to restart elections when no leader |
| 44 |
-- emerges soon enough. |
| 45 |
election_timeout=0.25, |
| 46 |
} |
| 47 |
|
| 48 |
box.schema.user.grant('guest', 'super', nil, nil, { if_not_exists = true }) |
| 49 |
|
| 50 |
centrifuge = require 'centrifuge' |
| 51 |
|
| 52 |
box.once("centrifuge:schema:1", function() |
| 53 |
centrifuge.init({ |
| 54 |
presence_temporary=true |
| 55 |
}) |
| 56 |
end) |
| 57 |
|
| 58 |
require'console'.start() |