-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upgrade sofa-bolt-node@2.0.1 (#70)
- Loading branch information
Showing
12 changed files
with
162 additions
and
63 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 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 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 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 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 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 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,27 @@ | ||
'use strict'; | ||
|
||
const zookeeper = require('zookeeper-cluster-client'); | ||
const { ACL, Permission, Id } = require('node-zookeeper-client'); | ||
|
||
async function main() { | ||
const client = zookeeper.createClient('127.0.0.1:2181', { | ||
authInfo: { | ||
scheme: 'digest', | ||
auth: 'gxcsoccer:123456', | ||
}, | ||
}); | ||
await client.mkdirp('/acl'); | ||
await client.setACL('/acl', [ | ||
new ACL( | ||
Permission.ALL, | ||
new Id('auth', 'gxcsoccer:123456') | ||
), | ||
], -1); | ||
|
||
const acls = await client.getACL('/acl'); | ||
console.log('acls', acls); | ||
} | ||
|
||
main().then(() => { | ||
process.exit(0); | ||
}); |
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 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,5 @@ | ||
'use strict'; | ||
|
||
const { start } = require('./zk'); | ||
|
||
start().catch(err => { console.log(err); }); |
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,5 @@ | ||
'use strict'; | ||
|
||
const { stop } = require('./zk'); | ||
|
||
stop().catch(err => { console.log(err); }); |
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,71 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const cp = require('child_process'); | ||
|
||
const cwd = path.join(__dirname, '../..'); | ||
|
||
async function detectZookeeper() { | ||
return new Promise(resolve => { | ||
const netstat = cp.spawn('netstat', [ '-an' ]); | ||
const grep = cp.spawn('grep', [ '2181' ]); | ||
|
||
netstat.stdout.on('data', data => { | ||
grep.stdin.write(data); | ||
}); | ||
|
||
netstat.stderr.on('data', data => { | ||
console.error(`netstat stderr: ${data}`); | ||
}); | ||
|
||
netstat.on('close', code => { | ||
if (code !== 0) { | ||
console.log(`netstat process exited with code ${code}`); | ||
} | ||
grep.stdin.end(); | ||
}); | ||
|
||
grep.stdout.on('data', data => { | ||
console.log(data.toString()); | ||
}); | ||
|
||
grep.stderr.on('data', data => { | ||
console.error(`grep stderr: ${data}`); | ||
}); | ||
|
||
grep.on('close', code => { | ||
if (code !== 0) { | ||
console.log(`grep process exited with code ${code}`); | ||
resolve(false); | ||
} else { | ||
resolve(true); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
async function extract() { | ||
cp.execSync('tar xf zookeeper-3.4.6.tar.gz', { cwd }); | ||
} | ||
|
||
exports.start = async () => { | ||
if (await detectZookeeper()) { | ||
return; | ||
} | ||
|
||
if (!fs.existsSync(path.join(cwd, 'zookeeper-3.4.6'))) { | ||
await extract(); | ||
} | ||
|
||
cp.execSync('cp zookeeper-3.4.6/conf/zoo_sample.cfg zookeeper-3.4.6/conf/zoo.cfg', { cwd }); | ||
cp.execSync('./zookeeper-3.4.6/bin/zkServer.sh start', { cwd }); | ||
}; | ||
|
||
exports.stop = async () => { | ||
const running = await detectZookeeper(); | ||
if (!running) { | ||
return; | ||
} | ||
cp.execSync('./zookeeper-3.4.6/bin/zkServer.sh stop', { cwd }); | ||
}; |
Binary file not shown.