Skip to content

Add new origins without restarting the proxy #1146

@jescalada

Description

@jescalada

Is your feature request related to a problem? Please describe.
As of v2.0.0, the proxy gets restarted when adding a new origin:

/src/routes/repo.js

let newOrigin = true;

const existingHosts = await getAllProxiedHosts();
existingHosts.forEach((h) => {
  // assume SSL is in use and that our origins are missing the protocol
  if (req.body.url.startsWith(`https://${h}`)) {
    newOrigin = false;
  }
});

// create the repository
const repoDetails = await db.createRepo(req.body);
const proxyURL = getProxyURL(req);

// return data on the new repoistory (including it's _id and the proxyUrl)
res.send({ ...repoDetails, proxyURL, message: 'created' });

// restart the proxy if we're proxying a new domain
if (newOrigin) {
  console.log('Restarting the proxy to handle an additional host');
  await theProxy.stop();
  await theProxy.start();
}

Since this causes a small downtime that may interrupt other users, we should refactor it to update the hosts without restarting, or at the very least making sure that other operations don't get interrupted.

Describe the solution you'd like
Refactor the routes/repo code to update the hosts without restarting (ideally).

Additional context
Original implementation PR: #1043

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions