Update proxy configuration on startup
gitea/docker-discover/pipeline/head This commit looks good
Details
gitea/docker-discover/pipeline/head This commit looks good
Details
This commit is contained in:
parent
4c3fe3abe5
commit
79671150c6
20
index.js
20
index.js
|
@ -16,7 +16,7 @@ const tmpDir = isProduction ? `/tmp/${appName}` : `${__dirname}/tmp`;
|
|||
const hashFile = `${tmpDir}/config.hash`;
|
||||
const confDir = conf.rproxy.confDir;
|
||||
|
||||
async function updateProxy() {
|
||||
async function updateProxy(firstRun) {
|
||||
console.log('Updating reverse proxy configuration.');
|
||||
|
||||
// Obtaining Docker settings
|
||||
|
@ -75,8 +75,7 @@ async function updateProxy() {
|
|||
const configString = template({
|
||||
services,
|
||||
nodes,
|
||||
info,
|
||||
acls: conf.acls
|
||||
info
|
||||
});
|
||||
|
||||
// Cheking settings hash
|
||||
|
@ -86,7 +85,7 @@ async function updateProxy() {
|
|||
.digest('hex');
|
||||
console.log('Settings hash:', infoHash);
|
||||
|
||||
if (lastInfoHash == infoHash) {
|
||||
if (lastInfoHash == infoHash && !firstRun) {
|
||||
console.log(`Settings haven't changed, aborting.`);
|
||||
return;
|
||||
}
|
||||
|
@ -119,11 +118,12 @@ async function updateProxy() {
|
|||
const sshClient = new ssh();
|
||||
await sshClient.connect(Object.assign({host}, conf.rproxy.auth));
|
||||
await sshClient.putFiles([files]);
|
||||
await sshClient.putDirectory(
|
||||
`${tmpDir}/maps`,
|
||||
`${confDir}/maps`,
|
||||
{recursive: true}
|
||||
);
|
||||
if (firstRun)
|
||||
await sshClient.putDirectory(
|
||||
`${tmpDir}/maps`,
|
||||
`${confDir}/maps`,
|
||||
{recursive: true}
|
||||
);
|
||||
if (conf.rproxy.reloadCmd)
|
||||
await sshClient.exec(conf.rproxy.reloadCmd);
|
||||
await sshClient.dispose();
|
||||
|
@ -303,7 +303,7 @@ async function updateProxy() {
|
|||
await fs.close(fd);
|
||||
}
|
||||
|
||||
await updateProxy();
|
||||
await updateProxy(true);
|
||||
|
||||
console.log('Listening for events.')
|
||||
docker.getEvents({}, (err, stream) => {
|
||||
|
|
Reference in New Issue