Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does multiple bot support #40

Open
TCmanna opened this issue Mar 7, 2024 · 2 comments
Open

does multiple bot support #40

TCmanna opened this issue Mar 7, 2024 · 2 comments

Comments

@TCmanna
Copy link

TCmanna commented Mar 7, 2024

Can multiple bot instances be supported? like using the same port 80 and using different web paths to view them

@Hellscaped
Copy link

use a reverse proxy like caddy for that

@sefirosweb
Copy link
Contributor

sefirosweb commented Mar 22, 2024

Hello, if the bot is execute on same server / instance first need to check if port is free,

export const getFreePort = (): Promise<number> => {
  return new Promise((resolve, reject) => {
    const server = require('net').createServer()
    server.unref()
    server.on('error', reject)
    server.listen(() => {
      const port = server.address().port as number
      server.close(() => {
        resolve(port)
      })
    })
  })
}

const port = await getFreePort()
inventoryViewer(bot, { port })

Second if yo want to share all bots using same port (80 / 443 secured) you need made a reverse proxy with express (this part is a more bit complicated)
Need any method to map the IP/port with the proxy, In my bot is used, also i added PR to support reverse proxy =)
https://github.com/sefirosweb/minecraftLegion/blob/f6dabe72fbe5af03161d92abdd235023fff77685/server/src/routes/viewer.ts#L62C7-L77

In my bot i use socket.io to connect to the server, there is the map
bot <-> server <-> web client

Example same webserver using reverse proxy
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants