Skip to content

Commit

Permalink
Add port 8081 for indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt committed Sep 11, 2024
1 parent 63a9f51 commit ee824cf
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 48 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ npm run dev -- --from-block=12345 # start indexing from the 12345th block
npm run dev -- --run-once # index and exit without watching for events
npm run dev -- --no-cache # disable cache
npm run dev -- --log-level=trace # set log level
npm run dev -- --port=8081 # start web service on a given port
```

## Running in production
Expand Down
29 changes: 26 additions & 3 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kill_timeout = '5s'
PASSPORT_SCORER_ID=335

[processes]
indexer = 'npm start -- --indexer --http'
indexer = 'npm start -- --indexer --http --port=8081'
web = 'npm start -- --http --http-wait-for-sync=false'

[[mounts]]
Expand All @@ -36,15 +36,38 @@ kill_timeout = '5s'
auto_extend_size_limit = "100GB"
processes = ['indexer', 'web']

[http_service]
[http_service.indexer]
internal_port = 8081
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1
processes = ['indexer']

[http_service.indexer.concurrency]
type = 'requests'
hard_limit = 250
soft_limit = 200

[checks.indexer_http]
port = 8081
type = 'http'
interval = '15s'
timeout = '10s'
grace_period = '30s'
method = 'get'
path = '/api/v1/status'
processes = ['indexer']

[http_service.web]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 2
processes = ['web']

[http_service.concurrency]
[http_service.web.concurrency]
type = 'requests'
hard_limit = 250
soft_limit = 200
Expand Down
103 changes: 58 additions & 45 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,53 @@ export type Config = {
};

export function getConfig(): Config {
const { values: args } = parseArgs({
options: {
"to-block": {
type: "string",
},
"from-block": {
type: "string",
},
"drop-db": {
type: "boolean",
},
"drop-chain-db": {
type: "boolean",
},
"drop-ipfs-db": {
type: "boolean",
},
"drop-price-db": {
type: "boolean",
},
"rm-cache": {
type: "boolean",
},
"log-level": {
type: "string",
},
"run-once": {
type: "boolean",
},
"no-cache": {
type: "boolean",
},
"http-wait-for-sync": {
type: "string",
},
http: {
type: "boolean",
},
indexer: {
type: "boolean",
},
port: {
type: "string",
},
},
});

const buildTag = z
.union([z.string(), z.null()])
.default(null)
Expand All @@ -1858,7 +1905,17 @@ export function getConfig(): Config {
.transform((value) => value === "true")
.parse(process.env.ENABLE_RESOURCE_MONITOR);

const apiHttpPort = z.coerce.number().parse(process.env.PORT);
const portSchema = z.number().int().nonnegative().max(65535);

const portOverride = z
.union([portSchema, z.undefined()])
.optional()
.parse(args["port"]);

const apiHttpPort =
portOverride !== undefined
? portOverride
: portSchema.parse(z.coerce.number().parse(process.env.PORT));

const pinoPretty = z
.enum(["true", "false"])
Expand Down Expand Up @@ -1899,50 +1956,6 @@ export function getConfig(): Config {
.default(path.join(storageDir, "cache"))
.parse(process.env.CACHE_DIR);

const { values: args } = parseArgs({
options: {
"to-block": {
type: "string",
},
"from-block": {
type: "string",
},
"drop-db": {
type: "boolean",
},
"drop-chain-db": {
type: "boolean",
},
"drop-ipfs-db": {
type: "boolean",
},
"drop-price-db": {
type: "boolean",
},
"rm-cache": {
type: "boolean",
},
"log-level": {
type: "string",
},
"run-once": {
type: "boolean",
},
"no-cache": {
type: "boolean",
},
"http-wait-for-sync": {
type: "string",
},
http: {
type: "boolean",
},
indexer: {
type: "boolean",
},
},
});

const chains = z
.string()
.or(z.literal("all"))
Expand Down

0 comments on commit ee824cf

Please sign in to comment.