Compare commits

...

4 Commits

Author SHA1 Message Date
Alex Moreno d29fd918cc Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/vn-rfid
gitea/vn-rfid/pipeline/head This commit looks good Details
2024-07-25 10:38:53 +02:00
Alex Moreno 842c141e13 feat: set to 0 counter when createPallet or not 2024-07-25 10:38:52 +02:00
Guillermo Bonet 16f6d60006 feat: refs #5144 Migration to kube
gitea/vn-rfid/pipeline/head This commit looks good Details
2024-06-13 09:04:14 +02:00
Alex Moreno 11cf68b3ad Merge pull request '5144-improveArc' (#5) from 5144-improveArc into master
gitea/vn-rfid/pipeline/head There was a failure building this commit Details
Reviewed-on: #5
2024-06-05 12:19:33 +00:00
4 changed files with 27 additions and 51 deletions

56
Jenkinsfile vendored
View File

@ -2,64 +2,54 @@
pipeline { pipeline {
agent any agent any
options {
disableConcurrentBuilds()
}
environment { environment {
PROJECT_NAME = 'vn-rfid' PROJECT_NAME = 'vn-rfid'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
} }
stages { stages {
stage('Checkout') { stage('Setup') {
steps { steps {
script { echo "NODE_NAME: ${env.NODE_NAME}"
switch (env.BRANCH_NAME) { echo "WORKSPACE: ${env.WORKSPACE}"
case 'master':
env.NODE_ENV = 'production'
break
}
}
setEnv()
} }
} }
stage('Build') { stage('Build') {
when { anyOf { when {
branch 'master' branch 'master'
}} }
environment { environment {
CREDENTIALS = credentials('docker-registry') CREDENTIALS = credentials('docker-registry')
} }
steps { steps {
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
dockerBuild() dockerBuild()
} }
} }
stage('Deploy') { stage('Deploy') {
when { anyOf { when {
branch 'master' branch 'master'
}}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
} }
steps { steps {
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
withKubeConfig([
serverUrl: "$KUBERNETES_API",
credentialsId: 'kubernetes',
namespace: 'vn-rfid'
]) {
sh 'kubectl set image deployment/vn-rfid vn-rfid=$REGISTRY/vn-rfid:$VERSION'
}
} }
} }
} }
post { post {
always { always {
script { setEnv()
if (!env.COMMITTER_EMAIL || currentBuild.currentResult == 'SUCCESS') return; sendEmail()
try {
mail(
to: env.COMMITTER_EMAIL,
subject: "Pipeline: ${env.JOB_NAME} (${env.BUILD_NUMBER}): ${currentBuild.currentResult}",
body: "Check status at ${env.BUILD_URL}"
)
} catch (e) {
echo e.toString()
}
}
} }
} }
} }

View File

@ -1,20 +1,7 @@
version: '3.7' version: '3.7'
services: services:
main: main:
image: registry.verdnatura.es/vn-rfid:${BRANCH_NAME:?} image: registry.verdnatura.es/vn-rfid:${VERSION:?}
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
ports:
- 8888
configs:
- source: config
target: /app/config.local.yml
deploy:
placement:
constraints:
- node.role == worker
configs:
config:
external: true
name: vn-rfid_config

View File

@ -1,12 +1,10 @@
import con from '../db/connect.js'; import con from '../db/connect.js';
import counter from './counter.js';
import t from '../util/translator.js'; import t from '../util/translator.js';
export default async(rfids, arcId) => { export default async(rfids, arcId) => {
try { try {
console.log(Array.from(rfids)); console.log(Array.from(rfids));
await con.query(`CALL vn.expeditionPallet_build(JSON_ARRAY(?), ?, ?, @palletId);`, [Array.from(rfids), arcId, null]); await con.query(`CALL vn.expeditionPallet_build(JSON_ARRAY(?), ?, ?, @palletId);`, [Array.from(rfids), arcId, null]);
await counter(null, arcId);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
await con.query(`UPDATE vn.arcRead SET error = ?, counter = NULL WHERE id = ?;`, [t(error.sqlMessage), arcId]); await con.query(`UPDATE vn.arcRead SET error = ?, counter = NULL WHERE id = ?;`, [t(error.sqlMessage), arcId]);

View File

@ -43,6 +43,7 @@ export default async(conf, cb) => {
newPallet(rfidbuffer, conf.arcId); newPallet(rfidbuffer, conf.arcId);
rfidbuffer = new Set(); rfidbuffer = new Set();
rfidbufferExtend = []; rfidbufferExtend = [];
counterIntervalManager();
} }
function counterIntervalManager() { function counterIntervalManager() {