Issue SCRUM#153: Remove references to legacy webservice

Signed-off-by: Lucas Fernandes de Oliveira's avatarLucas Fernandes de Oliveira <lfo14@inf.ufpr.br>
parent e758dbfb
Pipeline #14512 passed with stage
in 17 seconds
variables:
SIMMC_URL: 'marula.c3sl.ufpr.br:5000/c3sl/simmc'
WEBSERVICE_URL: 'marula.c3sl.ufpr.br:5000/c3sl/simmc-webservice'
stages:
- build
- deploy
......@@ -12,7 +11,6 @@ build:
script:
- PKG_VERSION=$(grep \"version\" portal/package.json | cut -f2 -d':'| sed -e 's/"\|,//g' | tr -d ' ')
- docker build -t ${SIMMC_URL}:${PKG_VERSION} -t ${SIMMC_URL}:latest portal
- docker build -t ${WEBSERVICE_URL}:${PKG_VERSION} -t ${WEBSERVICE_URL}:latest webservice
tags:
- docker
- build
......@@ -25,8 +23,6 @@ deploy:
- PKG_VERSION=$(grep \"version\" portal/package.json | cut -f2 -d':'| sed -e 's/"\|,//g' | tr -d ' ')
- docker push ${SIMMC_URL}:${PKG_VERSION}
- docker push ${SIMMC_URL}:latest
- docker push ${WEBSERVICE_URL}:${PKG_VERSION}
- docker push ${WEBSERVICE_URL}:latest
tags:
- docker
- build
......
......@@ -141,19 +141,15 @@ e o Portal acessível pelo navegador.
│   │   └── src
│   ├── routes - Definição de rotas para o server.js
│   └── scripts - Scripts auxiliares para o portal
├── scripts - Scripts auxiliares
│   ├── alerts - Scripts para gerar alertas periódicos
│   ├── apache2 - Configuração do apache2
│   ├── database_tasks - Tarefas relacionadas ao banco de dados
│   ├── digital_city - Tarefas relacionadas as cidades digitais
│   ├── gesac - Tarefas relacionadas ao projeto GESAC
│   ├── helpers - Scripts diversos
│   ├── init.d - Configuração do serviço simmc e simmc-webservice
│   └── openstreetmap - Scripts para criação de um servidor openstreetmap
└── webservice - Arquivos relacionados ao webservice de coleta de dados
├── lib - Bibliotecas usadas pelo server.js
├── logs - Arquivos de log gerados pelo server.js
└── parsers - Bibliotecas usadas pelo server.js
└── scripts - Scripts auxiliares
   ├── alerts - Scripts para gerar alertas periódicos
   ├── apache2 - Configuração do apache2
   ├── database_tasks - Tarefas relacionadas ao banco de dados
   ├── digital_city - Tarefas relacionadas as cidades digitais
   ├── gesac - Tarefas relacionadas ao projeto GESAC
   ├── helpers - Scripts diversos
   ├── init.d - Configuração do serviço simmc e simmc-webservice
   └── openstreetmap - Scripts para criação de um servidor openstreetmap
MAIS DOCUMENTAÇÃO
=================
......
......@@ -78,7 +78,6 @@ services:
simmc-webservice:
image: marula.c3sl.ufpr.br:5000/c3sl/simmc-webservice:latest
build: ../webservice
container_name: simmc-webservice
volumes:
-
......
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
node_modules
bower_components
build
tmp
npm-debug.log
config.js
app/config.json
sessions.db
reports/out
.git
*.swp
*.log
logs
config.js
node_modules
# Avoid the use of floating tags like: latest, boron, argon and carbon
ARG VERSION=6.12.2
FROM node:$VERSION
LABEL autor="C3SL - Centro de Computação Científica e Software Livre"
# Node was not designed to run as PID 1 (process in docker run with PID 1).
# Its recommended to use the flag --init or use tine to start node process
# in docker
# Add Tini
ENV TINI_VERSION="v0.16.1"
ENV WORKSPACE="/home/node/app/"
ENV NODE_ENV="production"
ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/node/app/node_modules/.bin"
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json $WORKSPACE
RUN \
chmod +x /tini &&\
chown -R node:node $WORKSPACE
USER node
WORKDIR $WORKSPACE
RUN npm install
# Bundle app source
# COPY copy files as root so chown must be used
USER root
COPY . .
RUN find . -user root | xargs chown node:node
USER node
EXPOSE 8000
#HEALTHCHECK CMD curl -f http://localhost:3000/api/ping || exit 1
# Instead of using npm start to start the container, directly put the command
# that npm start executes.
# First off this reduces the number of processes running inside of your container
# Secondly it causes exit signals such as SIGTERM and SIGINT to be received by
# the Node.js process instead of npm swallowing them.
ENTRYPOINT ["/tini", "-g", "--"]
CMD ["sh", "-c", "./docker_init.sh" ]
/*
* Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of simmc
*
* simmc is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
module.exports = function (grunt) {
grunt.initConfig({
// read the package.json (used in 'replace' task)
pkg: grunt.file.readJSON("package.json"),
// Run the server
express: {
options: {
script: 'server.js'
},
dev: {
options: {
node_env: 'development'
}
}
},
// Watch file changes
//
// Run the appropriate tasks whenever a related file changes
watch: {
gruntfile: {
files: [ 'Gruntfile.js' ],
tasks: [ 'default' ]
},
express: {
files: [ 'server.js', 'parsers/**/*.js', 'lib/**/*.js' ],
tasks: [ 'express:dev' ],
options: {
atBegin: true,
spawn: false
}
}
},
// Code linting
//
// Use jshint to check the code for suspicious language usage.
jshint: {
server: ['server.js' ]
},
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-express-server');
// default == dev mode
grunt.registerTask('default', [
'express:dev',
]);
grunt.registerTask('check', [
'jshint:server',
'jshint:client'
]);
};
var config = module.exports = {};
config.linux_agent_version = "$SIMMCWEBSERVICE_AGENT_LINUX_VERSION";
config.linux_agent_update_link = "http://$SIMMCWEBSERVICE_DOMAIN/download/datasid-1.0.0-update.run";
config.windows_agent_version = "$SIMMCWEBSERVICE_AGENT_WIN_VERSION";
config.windows_agent_update_link = "http://$SIMMCWEBSERVICE_DOMAIN/download/datasid-1.0.0-update.exe";
config.db = {
user: '$SIMMCWEBSERVICE_DB_USER',
password: '$SIMMCWEBSERVICE_DB_PASSWORD',
database: '$SIMMCWEBSERVICE_DB_NAME',
host: '$SIMMCWEBSERVICE_DB_HOST',
port: $SIMMCWEBSERVICE_DB_PORT
};
This diff is collapsed.
#! /bin/bash
basePath=$(echo $BASH_SOURCE | rev | cut -c 15- | rev)
cd $basePath
config=$(cat config.js.example)
vars=$(env | cut -f1 -d'=')
for v in $vars; do
config=$(echo "${config/\$$v/${!v}}")
done
echo "$config" > /tmp/config.js
if [[ $NODE_ENV == "production" ]]; then
node ./server.js --stdout-log -c /tmp/config.js
else
node ./server.js --dev --stdout-log -c /tmp/config.js
fi
/*
* Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of simmc
*
* simmc is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
var os = require('os');
var cluster = require('cluster');
var bunyan = require('bunyan');
var fs = require('fs');
// Create the default logger
/*var defaultLogger = bunyan.createLogger({
name: 'default',
streams: [{
level: "info",
type: 'file',
path: 'logs/default.log',
},
{
level: "debug",
type: 'file',
path: 'logs/debug.log',
}]
});
if (!cluster.isMaster) {
defaultLogger = defaultLogger.child({ worker: cluster.worker.id });
}*/
// Create the stdout logger
var stdoutLogger = bunyan.createLogger({
name: 'stdout'
});
if (!cluster.isMaster) {
stdoutLogger = stdoutLogger.child({ worker: cluster.worker.id });
}
// Export the default and stdout logger
//exports.default = defaultLogger;
module.exports = function(stdoutLog) {
var defaultLogger;
if (stdoutLog) {
// Create the stdout logger
defaultLogger = bunyan.createLogger({
name: 'stdout'
});
}
else {
// Make sure the logs dir exist
try {
fs.mkdirSync('logs');
}
catch (e) {
if ( e.code != 'EEXIST' )
throw e;
}
defaultLogger = bunyan.createLogger({
name: 'default',
streams: [{
level: "info",
type: 'file',
path: 'logs/default.log',
},
{
level: "debug",
type: 'file',
path: 'logs/debug.log',
}]
});
}
if (!cluster.isMaster) {
defaultLogger = defaultLogger.child({ worker: cluster.worker.id });
}
return defaultLogger;
};
/*
* Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of simmc
*
* simmc is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
var fs = require('fs');
var soap = require('soap');
var http = require('http');
var async = require('async');
module.exports = function () {
var services = [];
return {
service: function (name, url, wsdl) {
var svc = new Service(name, url, wsdl);
services.push(svc);
return svc;
},
listen: function (port, callback) {
if (!port) {
throw "Port not specified!";
}
// Setup a simple HTTP server
var server = http.createServer(function(req, res) {
res.end("404: Not Found: " + req.url);
});
server.listen(port, function () {
services.forEach(function (service) {
service.listen(server);
});
if (typeof callback === "function")
callback();
});
}
};
}
function Service(name, url, wsdl) {
this.name = name;
this.url = url;
// Read the service wsdl file
this.wsdl = fs.readFileSync(wsdl, 'utf8');
this.methods = [];
}
Service.prototype.listen = function(server) {
// Plug the SOAP server into the HTTP server
this.server = soap.listen(server,
this.url, this.getMethods(), this.wsdl);
// Monkey-patch the _envelope function fixing the soapenv namespace
// (for compatibility with datasid client).
this.server._envelope = function (body) {
var xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\" " +
this.wsdl.xmlnsInEnvelope + '>' +
"<soapenv:Body>" +
body +
"</soapenv:Body>" +
"</soapenv:Envelope>";
return xml;
}
};
Service.prototype.getName = function() {
return this.name;
};
Service.prototype.getUrl = function() {
return this.url;
};
Service.prototype.getWsdl = function() {
return this.wsdl;
};
Service.prototype.addMethod = function () {
if (arguments.length < 1)
throw "Missing method name";
if (arguments.length < 2)
throw "Missing method function";
var funcs = [];
for (var i=1; i<arguments.length; i++) {
funcs.push(arguments[i]);
}
var method = new Method(arguments[0], funcs);
this.methods.push(method);
return method;
};
Service.prototype.getMethods = function() {
var genericPort = {};
this.methods.forEach(function (method) {
genericPort[method.name] = function (args, callback) {
method.exec.call(method, args, callback);
};
});
var svc = {};
svc[this.name] = {};
svc[this.name][this.name+"HttpSoap12Endpoint"] = genericPort;
svc[this.name][this.name+"HttpSoap11Endpoint"] = genericPort;
svc[this.name][this.name+"HttpEndpoint"] = genericPort;
return svc;
};
function Method(name, funcs) {
this.name = name;
this.funcs = funcs;
};
Method.prototype.exec = function(args, callback) {
var cb_list = [];
var req = {
args: args,
method: this
};
var res = {
error: function (err) {
cb_list.forEach(function (cb) {
cb(err);
});
callback({
return: "ERROR: "+err
});
},
send: function (ret) {
cb_list.forEach(function (cb) {
cb();
});
callback({
return: ret
});
}
};
var funcCounter=0;
function callNext(next_cb) {
if (typeof next_cb === "function")
cb_list.push(next_cb);
if (funcCounter < req.method.funcs.length)
req.method.funcs[funcCounter++](req, res, callNext);
}
callNext();
};
/*
* Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of simmc
*
* simmc is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
var isValidDate = exports.isValidDate = function (d) {
if ( Object.prototype.toString.call(d) !== "[object Date]" )
return false;
return !isNaN(d.getTime());
}
var dateFormat = exports.dateFormat = function (date) {
if (!date) {
return null;
}
return date.getFullYear() + '-' +
("0" + (date.getMonth() + 1)).slice(-2) + '-' +
("0" + date.getDate()).slice(-2);
}
var timeFormat = exports.timeFormat = function (date) {
if (!date) {
return null;
}
return ("0" + date.getHours()).slice(-2) + ':' +
("0" + date.getMinutes()).slice(-2) + ':' +
("0" + date.getSeconds()).slice(-2);
}
var datetimeFormat = exports.datetimeFormat = function(datetime) {
if (!datetime) {
return null;
}
return dateFormat(datetime) + ' ' + timeFormat(datetime);
}
/*
* Most of the interesting bits are the regular expression which helps
* handle of these various scenarios. It takes a string representation of a
* time and attempts to parse it, setting the time on the specified date
* object sent to the function as the second parameter. In the case where
* you do not provide a second parameter, the current date will be used.
* http://www.timlabonne.com/2013/07/parsing-a-time-string-with-javascript/
*/
var parseTime = exports.parseTime = function (timeStr, dt) {
if (!dt) {
dt = new Date();
}
var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i);
if (!time) {
return null;
}
var hours = parseInt(time[1], 10);
if (hours == 12 && !time[3]) {
hours = 0;
}
else {
hours += (hours < 12 && time[3]) ? 12 : 0;
}
dt.setHours(hours);
dt.setMinutes(parseInt(time[2], 10) || 0);
dt.setSeconds(0, 0);
return dt;
}
var csvify = exports.csvify = function (p) {
if ((typeof p === 'undefined') || (p === null)) {
return 'null';
}
else if (typeof p === 'number') {
return isNaN(p) ? 'null' : (p+'');
}
else if (typeof p === 'string') {
return '"'+p+'"';
}
else if (typeof p === 'boolean') {
return p ? 't' : 'f';
}
else {
return p;
}
}
{
"name": "simmc-webservice",
"version": "1.0.0",
"description": "A SOAP webservice for the simmc agent (datasid)",
"main": "server.js",
"private": true,
"scripts": {
"start": "node server.js"
},
"author": "c3sl - Centro de Computação e Software Livre",
"license": "GNU GPLv3",
"dependencies": {
"async": "^1.1.0",
"bunyan": "^1.2.0",
"daemon": "^1.1.0",
"http": "0.0.0",
"libxmljs": "^0.18.7",
"minimist": "^1.1.0",
"pg": "^4.4.3",
"soap": "^0.10.3",
"utf8": "^2.0.0",
"pg-copy-streams": "^0.3.0"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-jshint": "^0.11.3",
"grunt-contrib-watch": "^0.6.1",
"grunt-express-server": "^0.5.1"
},
"repository": {
"type": "git",
"url": "http://git.c3sl.ufpr.br/minicom/simmc.git"
},
"keywords": [
"simmc",
"minicom",
"webservice"
]
}
/*
* Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of simmc
*
* simmc is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
//
// Setup logger
//
var logger = require('../lib/logger.js');
var log;
var util = require("../lib/util.js");
var libxmljs = require("libxmljs");
var MACHINE_TYPE_CLIENT = 0,
MACHINE_TYPE_SERVER = 1;
module.exports = function(stdoutLog) {
log = logger(stdoutLog);
return parser;
};
function parser (xmlData, callback) {
if (!xmlData)
return callback("invalid inventory XML");