Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
keeleliin-wrapper
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
keeleliin
keeleliin-wrapper
Commits
9e8ef6d6
Commit
9e8ef6d6
authored
Nov 05, 2015
by
priit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dockeri alge
parent
722fed14
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
67 deletions
+151
-67
README.MD
README.MD
+9
-2
config_dist.js
config_dist.js
+63
-50
global_config/global.js
global_config/global.js
+2
-11
src/model/session.js
src/model/session.js
+4
-4
wrapper/LocalCommandTemplate.js
wrapper/LocalCommandTemplate.js
+73
-0
No files found.
README.MD
View file @
9e8ef6d6
...
...
@@ -4,7 +4,7 @@
$ docker run --name kl_redis -d redis
*
Lae alla keeleliin-
server
Dockerfile
*
Lae alla keeleliin-
wrapper-service
Dockerfile
*
Loo dockeri Image fail
...
...
@@ -12,6 +12,13 @@ $ docker build -t kl_wrapper_name .
*
Käivita loodud kl_wrapper_name
$ docker run --name kl_wrapper_name -d --link kl_redis:redis -p 3000:3000 -v /wrapper/concat/:/config kl_wrapper_name
$ docker run --name kl_wrapper_name -d --link kl_redis:redis -p 3000:3000 -v /wrapper/concat:/config kl_wrapper_name
*
Muuda teenuse seadistusi /wrapper/concat/config.js
*
Uuenda teenust
$ docker exec kl_wrapper_name /src/docker_update.sh
config_dist.js
View file @
9e8ef6d6
var
config
=
require
(
'
./global_config/global
'
);
//config.serverUrl = 'http://localhost';
/*
* Teenuse url ilma pordita. Kasutatakse teenuse serverisse installeerimisel teenuse urli moodustamiseks: <url>:<port>/api/v1/
*/
config
.
serverUrl
=
'
http://localhost
'
;
/*
* Redis serveri andmed. Kui kasutatakse vaikeseadeid, siis pole vaja muuta
*/
//config.redis = {
// host: process.env.REDIS_PORT_6379_TCP_ADDR || "127.0.0.1",
// port: process.env.REDIS_PORT_6379_TCP_PORT || 6379
//};
/*
* Nimekiri keeleliini serverirakendustest, kuhu teenuse käivitamisel see installeeritakse.
*/
//config.integration = [
// {
// installUrl: 'http://keeleliin.keeleressursid.ee:3000/api/v1/service/install',
...
...
@@ -15,61 +23,68 @@ var config = require('./global_config/global');
// }
//];
/*
* Teenuse failide salvestamise asukohad
*/
//config.fs = {
// storagePath:
"/wrapper/files"
,
// tmpPath:
"/wrapper/tmp"
// storagePath:
'/wrapper/files'
,
// tmpPath:
'/wrapper/tmp'
//};
/*config.log4js.appenders.push({
"type": "logLevelFilter",
"level": "ERROR",
"appender": {
"type": "smtp",
"layout": {
/*
* Kui teenuse töös peaks tekkima vigu ja selle kohta soovitakse veadeadet emailile saada,
* siis tuleks see sisse kommenteerida ja *** väjad täita
*/
/* config.log4js.appenders.push({
"type": "logLevelFilter",
"level": "ERROR",
"appender": {
"type": "smtp",
"layout": {
type: 'pattern',
pattern: "[%d] [%x{port}-%x{pid}][%5.5p] %c - %m",
tokens: {
pid: process.pid,
port: config.port
}
pid: process.pid,
port: config.port
}
},
"recipients": "***********",
"sendInterval": 10, //sec
"transport": "SMTP",
"SMTP": {
"host": "smtp.gmail.com",
"secureConnection": false,
"port": 587,
"auth": {
"user": "***********",
"pass": "***********"
},
"debug": true
}
"recipients": "***@***.***", //komaga eraldatult eposti aadressid
"sendInterval": 10, //sec
"transport": "SMTP",
"SMTP": {
"host": "smtp.gmail.com",
"secureConnection": false,
"port": 587,
"auth": {
"user": "***",
"pass": "***"
},
"debug": true
}
}
}
});*/
);
*/
config
.
wrapper
=
{
id
:
'
concat
'
,
//
u
nikaalne lühinimi
config
.
wrapper
=
{
//teenuse seadistus
id
:
'
concat
'
,
//
U
nikaalne lühinimi
title
:
'
Lihtne konjateneerija
'
,
//Avalik nimi
description
:
'
Konkateneerib etteantud failid üheks suureks failiks
'
,
//Kirjeldus
port
:
3000
,
//port
class
:
'
simpleLocalCommand
'
,
//wrapperi failinimi wrapper kaustast, mida utiliidi käivitamiseks kasutatakse
command
:
'
cat [data]
'
,
// utiliidi käsurea käsk
requestConf
:
{
//Päringu seadistus
requestBodyParamsMappings
:
{
isAsync
:
{
type
:
config
.
paramTypes
.
SELECT
,
options
:
[
'
0
'
,
'
1
'
],
value
:
'
1
'
,
usageType
:
config
.
paramUsageTypes
.
META
,
filter
:
function
(
value
)
{
requestBodyParamsMappings
:
{
//Päringu post parameetrid
isAsync
:
{
//parameeter isAsync
type
:
config
.
paramTypes
.
SELECT
,
//Tüüp. Võimalikud väärtused: config.paramTypes.SELECT ja config.paramTypes.TEXT
options
:
[
'
0
'
,
'
1
'
],
//Võimalikud sobivad väärtused
value
:
'
1
'
,
//Soovituslik vaikeväärtus
filter
:
function
(
value
)
{
//parameerile rakendatav filter. Antud juhul viiaks väärtus boolean kujule
return
value
==
1
;
},
required
:
true
,
allowEmpty
:
false
,
validator
:
function
(
value
,
request
)
{
required
:
true
,
//kas mittetühi väärtus on nõutud
allowEmpty
:
false
,
//kas parameeter peab olema saadetud
validator
:
function
(
value
,
request
)
{
//filtreeritud väärtuse valideerimine
if
(
typeof
value
!=
'
boolean
'
){
request
.
setMessage
(
'
isAsync
'
,
'
Peab olema boolean
'
);
return
false
;
...
...
@@ -78,24 +93,22 @@ config.wrapper = {
}
}
},
requestFiles
:
{
content
:
{
type
:
'
text
'
,
sizeLimit
:
0
,
sizeUnit
:
'
byte
'
,
isList
:
true
requestFiles
:
{
//Päringuga saadetavad failid
content
:
{
//Faili võti
type
:
'
text
'
,
//Ressursi tüübi võti
sizeLimit
:
0
,
//Suuruse piirang
sizeUnit
:
'
byte
'
,
//Suuruse piirangu ühik
isList
:
true
//Kas tegemist võib olla ka failide listuga
}
}
},
outputTypes
:
[
//teenuse väljundressursside kirjldused
{
type
:
'
text
'
,
key
:
'
output
'
type
:
'
text
'
,
//ressursi tüüp
key
:
'
output
'
//väljundressursi võti
}
],
sessionMaxLifetime
:
600
// sessiooni maksimaalne kestvus
};
module
.
exports
=
config
;
\ No newline at end of file
global_config/global.js
View file @
9e8ef6d6
...
...
@@ -8,10 +8,10 @@ config.redis = {
config
.
serverUrl
=
'
http://localhost
'
;
config
.
integration
=
[
{
/*
{
installUrl: 'http://keeleliin.keeleressursid.ee:3000/api/v1/service/install',
apiKey: 'server-wrapper-api-key'
}
}
*/
];
config
.
fs
=
{
...
...
@@ -24,12 +24,6 @@ config.paramTypes = {
SELECT
:
'
select
'
};
config
.
paramUsageTypes
=
{
META
:
'
meta
'
,
//ei kasutata utiliidi parameetrina
STRING
:
'
string
'
,
//parameeter asendatakse väärtusega
FILE
:
'
file
'
//parameeteri väärtus salvestatakse faili ja faili pathi kasutatakse argumendina
};
config
.
log4js
=
{
appenders
:
[
{
...
...
@@ -74,7 +68,6 @@ config.isAsyncParamDescription = {
type
:
config
.
paramTypes
.
SELECT
,
options
:
[
'
0
'
,
'
1
'
],
value
:
'
1
'
,
usageType
:
config
.
paramUsageTypes
.
META
,
filter
:
function
(
value
)
{
return
value
==
1
;
},
...
...
@@ -88,7 +81,6 @@ config.isAsyncParamDescription = {
config
.
stringKeyDescription
=
{
type
:
config
.
paramTypes
.
TEXT
,
value
:
undefined
,
usageType
:
config
.
paramUsageTypes
.
STRING
,
filter
:
null
,
required
:
false
,
allowEmpty
:
true
,
...
...
@@ -100,7 +92,6 @@ config.stringKeyDescription = {
config
.
fileKeyDescription
=
{
type
:
config
.
paramTypes
.
TEXT
,
value
:
undefined
,
usageType
:
config
.
paramUsageTypes
.
FILE
,
filter
:
null
,
required
:
false
,
allowEmpty
:
true
,
...
...
src/model/session.js
View file @
9e8ef6d6
...
...
@@ -36,12 +36,12 @@ Session.prototype.getFile = function( key ){
};
Session
.
prototype
.
getFiles
=
function
(
key
){
var
fileValue
=
this
.
requestFiles
[
key
];
var
fileValue
s
=
this
.
requestFiles
[
key
];
if
(
Array
.
isArray
(
fileValue
)){
return
fileValue
;
if
(
Array
.
isArray
(
fileValue
s
)){
return
fileValue
s
;
}
return
[
fileValue
];
return
[
fileValue
s
];
};
Session
.
messages
=
{
...
...
wrapper/LocalCommandTemplate.js
0 → 100644
View file @
9e8ef6d6
var
logger
=
require
(
'
log4js
'
).
getLogger
(
'
simple_local_command_wrapper
'
);
var
config
=
require
(
'
./../config
'
);
var
localExecutor
=
require
(
'
./../src/service/executor/localExecutor
'
);
var
Session
=
require
(
'
../src/model/session
'
);
var
CommandModel
=
require
(
'
../src/mapper/commandModel
'
);
var
fs
=
require
(
'
fs
'
);
var
mime
=
require
(
'
mime
'
);
var
path
=
require
(
'
path
'
);
var
FileUtil
=
require
(
'
./../src/util/file
'
);
function
LocalCommandTemplate
(){
var
self
=
this
;
/*
* Funktsioon töö tegemiseks
*/
this
.
process
=
function
(
session
,
callback
)
{
self
.
_getCommandModel
(
session
,
function
(
err
,
model
)
{
logger
.
debug
(
'
GetCommandModel callback
'
);
if
(
err
){
logger
.
error
(
err
);
return
callback
(
err
);
}
localExecutor
.
execute
(
model
,
session
,
function
(
err
,
response
)
{
if
(
err
)
return
callback
(
err
);
logger
.
debug
(
'
Program is finished
'
);
if
(
response
.
isSuccess
){
session
.
message
=
Session
.
messages
.
OK
;
}
else
{
session
.
setErrors
(
response
.
errors
);
}
session
.
addOutputFile
(
'
output
'
,
{
type
:
'
output
'
,
fileName
:
config
.
wrapper
.
id
+
'
_output.
'
+
FileUtil
.
getExtension
(
response
.
stdOutPath
),
filePath
:
response
.
stdOutPath
,
contentType
:
mime
.
lookup
(
response
.
stdOutPath
)
});
return
callback
(
err
,
session
);
});
});
};
this
.
_getCommandModel
=
function
(
session
,
callback
)
{
var
model
=
new
CommandModel
();
model
.
serviceProperties
.
commandTemplate
=
config
.
wrapper
.
command
.
commandTemplate
;
model
.
init
(
session
);
model
.
setKeyValue
(
'
data
'
,
session
.
getFiles
(
'
content
'
));
//model.setStdOutExtension('txt'); //stdout faili laiend
//model.setFileValue(key, value);
//model.addOutputPath(key, options); // options: {extension: 'txt'}
model
.
render
(
function
(
err
)
{
logger
.
debug
(
'
Render callback
'
);
callback
(
err
,
model
);
});
};
/*
* Meetod töötava utiliidi peatamiseks
*/
this
.
kill
=
localExecutor
.
kill
;
}
module
.
exports
=
LocalCommandTemplate
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment