exit redis client after exit
Some checks failed
Build and push image for doorman / docker (push) Failing after 24s
Some checks failed
Build and push image for doorman / docker (push) Failing after 24s
This commit is contained in:
parent
79b03574ff
commit
9f5a9be29e
@ -17,9 +17,9 @@ jobs:
|
|||||||
- name: Login and Push Docker image
|
- name: Login and Push Docker image
|
||||||
run: echo -n '${{ secrets.PASSWORD }}' | docker login gitea.chromart.dedyn.io --username ${{ secrets.USERNAME }} --password-stdin && docker image push --all-tags gitea.chromart.dedyn.io/martin/doorman
|
run: echo -n '${{ secrets.PASSWORD }}' | docker login gitea.chromart.dedyn.io --username ${{ secrets.USERNAME }} --password-stdin && docker image push --all-tags gitea.chromart.dedyn.io/martin/doorman
|
||||||
|
|
||||||
deploy-portainer:
|
# deploy-portainer:
|
||||||
needs: docker
|
# needs: docker
|
||||||
runs-on: ubuntu-22.04
|
# runs-on: ubuntu-22.04
|
||||||
steps:
|
# steps:
|
||||||
- name: Call Portainer stack webhook
|
# - name: Call Portainer stack webhook
|
||||||
run: curl --request POST http://192.168.1.150:9000/api/stacks/webhooks/42b3ae11-45bb-4021-b274-bedcb1250892
|
# run: curl --request POST http://192.168.1.150:9000/api/stacks/webhooks/42b3ae11-45bb-4021-b274-bedcb1250892
|
||||||
@ -23,29 +23,29 @@ exports.handler = function(context, event, callback) {
|
|||||||
return callback(null, response);
|
return callback(null, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
door = door.toUpperCase();
|
if (!context['FIXED_PIN_' + door.toUpperCase()]) {
|
||||||
|
|
||||||
if (!context['FIXED_PIN_' + door]) {
|
|
||||||
response.setStatusCode(404);
|
response.setStatusCode(404);
|
||||||
return callback(null, response);
|
return callback(null, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
let correctPin = context['FIXED_PIN' + door];
|
let correctPin = context['FIXED_PIN_' + door.toUpperCase()];
|
||||||
|
|
||||||
if (correctPin !== pin) {
|
if (correctPin !== pin) {
|
||||||
response.setStatusCode(401);
|
response.setStatusCode(401);
|
||||||
return callback(null, response);
|
return callback(null, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
let client = new redis.RedisDbClient((err) => console.error(err), { url: context.REDIS_CONNECT_URL });
|
let client = redis.createClient({ url: context.REDIS_CONNECT_URL });
|
||||||
client.connect()
|
client.connect()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const statusKey = doorStatusKey(door);
|
const statusKey = doorStatusKey(door);
|
||||||
const fingerprint = { method: "PIN" };
|
const fingerprint = { method: "PIN" };
|
||||||
const timeout = context['OPEN_TIMEOUT_' + door] || 60;
|
const timeout = context['OPEN_TIMEOUT_' + door.toUpperCase()] || 60;
|
||||||
|
|
||||||
|
await client.set(statusKey, JSON.stringify(fingerprint));
|
||||||
|
await client.expire(statusKey, timeout);
|
||||||
|
await client.quit();
|
||||||
|
|
||||||
await client.put(statusKey, JSON.stringify(fingerprint));
|
|
||||||
await client.getClient().expire(statusKey, timeout);
|
|
||||||
response
|
response
|
||||||
.setStatusCode(200)
|
.setStatusCode(200)
|
||||||
.appendHeader('Content-Type', 'application/json')
|
.appendHeader('Content-Type', 'application/json')
|
||||||
|
|||||||
@ -22,22 +22,18 @@ exports.handler = function(context, event, callback) {
|
|||||||
return callback(null, response);
|
return callback(null, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
door = door.toUpperCase();
|
const timeout = context['OPEN_TIMEOUT_' + door.toUpperCase()] || 60;
|
||||||
|
|
||||||
const timeout = context['OPEN_TIMEOUT_' + door] || 60;
|
let client = redis.createClient({ url: context.REDIS_CONNECT_URL });
|
||||||
|
|
||||||
|
|
||||||
res.status(200).json();
|
|
||||||
|
|
||||||
let client = new RedisDbClient((err) => console.error(err), { url: context.REDIS_CONNECT_URL });
|
|
||||||
client.connect()
|
client.connect()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const status = await client.get(doorStatusKey(door)) ? "OPEN": "CLOSED";
|
const status = await client.get(doorStatusKey(door)) ? "OPEN": "CLOSED";
|
||||||
|
await client.quit();
|
||||||
|
|
||||||
response
|
response
|
||||||
.setStatusCode(200)
|
.setStatusCode(200)
|
||||||
.appendHeader('Content-Type', 'application/json')
|
.appendHeader('Content-Type', 'application/json')
|
||||||
.setBody({ id: doorId, timeout, status });
|
.setBody({ id: door, timeout, status });
|
||||||
|
|
||||||
return callback(null, response);
|
return callback(null, response);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -22,7 +22,7 @@ exports.handler = function(context, event, callback) {
|
|||||||
return callback(null, response);
|
return callback(null, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
let client = new RedisDbClient((err) => console.error(err), { url: context.REDIS_CONNECT_URL });
|
let client = redis.createClient({ url: context.REDIS_CONNECT_URL });
|
||||||
client.connect()
|
client.connect()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const isOpen = await client.get(doorStatusKey(door));
|
const isOpen = await client.get(doorStatusKey(door));
|
||||||
@ -34,10 +34,11 @@ exports.handler = function(context, event, callback) {
|
|||||||
.setStatusCode(200)
|
.setStatusCode(200)
|
||||||
.appendHeader('Content-Type', 'application/json')
|
.appendHeader('Content-Type', 'application/json')
|
||||||
.setBody({
|
.setBody({
|
||||||
status: "OPEN",
|
status: "OPEN",
|
||||||
fingerprint,
|
fingerprint,
|
||||||
});
|
});
|
||||||
await client.remove(doorStatusKey(req.params.id));
|
await client.getDel(doorStatusKey(door));
|
||||||
|
await client.quit();
|
||||||
|
|
||||||
return callback(null, response);
|
return callback(null, response);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user