Skip to content

Commit

Permalink
feat(core): support appOptions.host, fix #350
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Aug 23, 2021
1 parent bb737d2 commit 4819ab3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/koishi-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface DelayOptions {

export interface AppOptions extends BotOptions {
port?: number
host?: string
bots?: BotOptions[]
prefix?: string | string[] | ((session: Session.Message) => void | string | string[])
nickname?: string | string[]
Expand Down Expand Up @@ -176,10 +177,10 @@ export class App extends Context {

private async _listen() {
try {
const { port } = this.app.options
const { port, host } = this.app.options
if (port) {
this._httpServer.listen(port)
this.logger('server').info('server listening at %c', port)
this._httpServer.listen(port, host)
this.logger('server').info('server listening at %c', `http://${host || 'localhost'}:${port}`)
}
await Promise.all(Object.values(this.adapters).map(adapter => adapter.start()))
} catch (error) {
Expand Down

0 comments on commit 4819ab3

Please sign in to comment.