Skip to content

Commit

Permalink
add listenhost option
Browse files Browse the repository at this point in the history
  • Loading branch information
benharri committed May 22, 2023
1 parent 1890c9c commit 1b2f04a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Whichever port you want to run this on
FEEDGEN_PORT=3000

# Change this to use a different bind address
FEEDGEN_LISTENHOST="localhost"

# Set to something like db.sqlite to store persistently
FEEDGEN_SQLITE_LOCATION=":memory:"

Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type AppContext = {

export type Config = {
port: number
listenhost: string
hostname: string
sqliteLocation: string
subscriptionEndpoint: string
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const run = async () => {
maybeStr(process.env.FEEDGEN_SERVICE_DID) ?? `did:web:${hostname}`
const server = FeedGenerator.create({
port: maybeInt(process.env.FEEDGEN_PORT) ?? 3000,
listenhost: maybeStr(process.env.FEEDGEN_LISTENHOST) ?? 'localhost',
sqliteLocation: maybeStr(process.env.FEEDGEN_SQLITE_LOCATION) ?? ':memory:',
subscriptionEndpoint:
maybeStr(process.env.FEEDGEN_SUBSCRIPTION_ENDPOINT) ??
Expand All @@ -17,7 +18,7 @@ const run = async () => {
})
await server.start()
console.log(
`🤖 running feed generator at http://localhost:${server.cfg.port}`,
`🤖 running feed generator at http://${server.cfg.listenhost}:${server.cfg.port}`,
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class FeedGenerator {
async start(): Promise<http.Server> {
await migrateToLatest(this.db)
this.firehose.run()
this.server = this.app.listen(this.cfg.port)
this.server = this.app.listen(this.cfg.port, this.cfg.listenhost)
await events.once(this.server, 'listening')
return this.server
}
Expand Down

0 comments on commit 1b2f04a

Please # to comment.