-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathindex.ts
42 lines (32 loc) · 1.17 KB
/
index.ts
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
#!/usr/bin/env -S node --no-warnings
import { createAztecNodeClient } from '@aztec/circuit-types';
import { init } from '@aztec/foundation/crypto';
import { createLogger } from '@aztec/foundation/log';
import { getPXEServiceConfig } from '../config/index.js';
import { startPXEHttpServer } from '../pxe_http/index.js';
import { createPXEService } from '../pxe_service/create_pxe_service.js';
const { PXE_PORT = 8080, AZTEC_NODE_URL = 'http://localhost:8079' } = process.env;
const logger = createLogger('pxe:service');
/**
* Create and start a new PXE HTTP Server
*/
async function main() {
logger.info(`Setting up PXE...`);
await init();
const pxeConfig = getPXEServiceConfig();
const nodeRpcClient = createAztecNodeClient(AZTEC_NODE_URL);
const pxeService = await createPXEService(nodeRpcClient, pxeConfig);
const shutdown = async () => {
logger.info('Shutting down...');
await pxeService.stop();
process.exit(0);
};
process.once('SIGINT', shutdown);
process.once('SIGTERM', shutdown);
startPXEHttpServer(pxeService, PXE_PORT);
logger.info(`PXE listening on port ${PXE_PORT}`);
}
main().catch(err => {
logger.error(err);
process.exit(1);
});