blob: 2da53aee29b8f73e6952b0014a5e45c937faf059 [file] [log] [blame]
wilfrem2c69b5a2015-04-20 19:24:50 +09001import thrift = require("thrift");
2var program = require('commander');
3import ThriftTest = require('./gen-nodejs/ThriftTest');
4import test_handler = require('./test_handler');
5
6
7program
8 .option('--port <port>', 'Set thrift server port', 9090)
9 .option('--promise', 'test with promise style functions')
10 .option('--protocol', '"Set thrift protocol (binary) [protocol]"')
11 .parse(process.argv);
12
13var port: number = program.port;
14
15var options: thrift.ServerOptions = {
16 transport: thrift.TBufferedTransport,
17 protocol: thrift.TBinaryProtocol
18};
19
20var server: thrift.Server;
21if (program.promise) {
22 server = thrift.createServer(ThriftTest.Processor, new test_handler.AsyncThriftTestHandler(), options);
23} else {
24 server = thrift.createServer(ThriftTest.Processor, new test_handler.SyncThriftTestHandler(), options);
25}
26server.listen(port);