File: ha.lua

package info (click to toggle)
golang-github-centrifugal-centrifuge 0.15.0%2Bgit20210306.f435ba2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,612 kB
  • sloc: javascript: 102; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,898 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'strict'.on()
fiber = require 'fiber'

local instance_id = string.match(arg[1], '^%d+$')
assert(instance_id, 'malformed instance id')

local port = 3300 + instance_id
local workdir = 'ha_tnt'..instance_id

box.cfg{
    listen = '0.0.0.0:'..port,
    wal_dir = workdir,
    memtx_dir = workdir,
    readahead = 10 * 1024 * 1024, -- to keep up with benchmark load.
    net_msg_max = 1024, -- to keep up with benchmark load.

    instance_uuid='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa'..instance_id,

    replication = {
        'tnt1:'..3301,
        'tnt2:'..3302,
        'tnt3:'..3303,
    },
    replication_connect_quorum=0,

    -- The instance is set to candidate, so it may become leader itself
    -- as well as vote for other instances.
    --
    -- Alternative: set one of the three instances to `voter`, so that it
    -- never becomes a leader but still votes for one of its peers and helps
    -- it reach election quorum (2 in our case).
    election_mode='candidate',
    -- Quorum for both synchronous transactions and
    -- leader election votes.
    replication_synchro_quorum=2,
    -- Synchronous replication timeout. The transaction will be
    -- rolled back if no quorum is achieved during 1 second.
    replication_synchro_timeout=1,
    -- Heartbeat timeout. A leader is considered dead if it doesn't
    -- send heartbeats for 4 * replication_timeout (1 second in our case).
    -- Once the leader is dead, remaining instances start a new election round.
    replication_timeout=0.25,
    -- Timeout between elections. Needed to restart elections when no leader
    -- emerges soon enough.
    election_timeout=0.25,
}

box.schema.user.grant('guest', 'super', nil, nil, { if_not_exists = true })

centrifuge = require 'centrifuge'

box.once("centrifuge:schema:1", function()
    centrifuge.init({
        presence_temporary=true
    })
end)

require'console'.start()