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
4058ad4f
Commit
4058ad4f
authored
Sep 29, 2015
by
priit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utiliidi töö katkestamine
parent
04171f4e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
91 deletions
+80
-91
controllers/api/v1/service.js
controllers/api/v1/service.js
+6
-5
src/service/integration/installService.js
src/service/integration/installService.js
+19
-52
wrapper_configs/global.js
wrapper_configs/global.js
+41
-32
www/server.js
www/server.js
+14
-2
No files found.
controllers/api/v1/service.js
View file @
4058ad4f
...
...
@@ -6,6 +6,11 @@ var wrapperService = require(__base + '/src/service/wrapperService');
var
fs
=
require
(
'
fs
'
);
var
installService
=
require
(
__base
+
'
/src/service/integration/installService
'
);
router
.
get
(
'
/config
'
,
function
(
req
,
res
)
{
return
res
.
send
(
installService
.
getConfiguration
());
});
router
.
post
(
'
/
'
,
function
(
req
,
res
)
{
logger
.
debug
(
req
.
body
);
...
...
@@ -69,10 +74,6 @@ router.get('/:sessionId/kill', function(req, res) {
});
});
router
.
get
(
'
/install/external
'
,
function
(
req
,
res
)
{
installService
.
install
(
function
(
err
,
result
)
{
return
res
.
send
({
errors
:
err
,
data
:
result
});
});
});
module
.
exports
=
router
;
src/service/integration/installService.js
View file @
4058ad4f
...
...
@@ -7,32 +7,26 @@ var InstallService = function() {
var
self
=
this
;
this
.
install
=
function
(
cb
)
{
var
wrapper
=
config
.
wrapper
;
var
serviceConfig
=
self
.
getConfiguration
();
serviceConfig
.
apiKey
=
config
.
integration
.
apiKey
;
request
.
post
({
url
:
self
.
_composeInstallUrl
(
config
.
integration
.
installUrl
,
wrapper
.
id
,
self
.
_getApiKey
())
,
json
:
se
lf
.
getConfiguration
()
url
:
config
.
integration
.
installUrl
,
json
:
se
rviceConfig
},
function
(
error
,
response
,
body
)
{
logger
.
error
(
'
1
'
,
error
);
logger
.
error
(
'
2
'
,
response
);
logger
.
error
(
'
3
'
,
body
);
if
(
error
)
{
logger
.
error
(
error
);
return
cb
(
error
);
}
var
data
=
{
errors
:
null
,
data
:
null
};
if
(
body
!=
undefined
)
{
if
(
body
.
errors
)
{
data
.
errors
=
body
.
errors
;
}
if
(
body
.
data
)
{
data
.
data
=
body
.
data
;
}
}
logger
.
debug
(
data
);
return
cb
(
data
.
errors
,
data
.
data
);
});
};
...
...
@@ -44,7 +38,7 @@ var InstallService = function() {
configuration
.
sid
=
wrapper
.
id
;
configuration
.
name
=
wrapper
.
title
;
configuration
.
description
=
wrapper
.
description
;
configuration
.
url
=
self
.
_composeUrl
(
config
.
serverUrl
,
wrapper
.
port
)
;
configuration
.
url
=
config
.
serverUrl
+
'
:
'
+
wrapper
.
port
+
'
/api/v1/
'
;
configuration
.
inputTypes
=
[];
configuration
.
outputTypes
=
[];
...
...
@@ -72,14 +66,12 @@ var InstallService = function() {
var
requestBodyTemplate
=
wrapper
.
requestConf
.
requestBodyTemplate
;
for
(
var
property
in
requestBodyTemplate
){
if
(
requestBodyTemplate
.
hasOwnProperty
(
property
))
{
if
(
wrapper
.
requestConf
.
requestBodyParamsMappings
[
property
].
usageType
!=
config
.
paramUsageTypes
.
META
)
{
configuration
.
parameters
.
push
({
key
:
property
,
type
:
wrapper
.
requestConf
.
requestBodyParamsMappings
[
property
].
type
,
value
:
requestBodyTemplate
[
property
]
});
}
configuration
.
parameters
.
push
({
key
:
property
,
type
:
wrapper
.
requestConf
.
requestBodyParamsMappings
[
property
].
type
,
options
:
wrapper
.
requestConf
.
requestBodyParamsMappings
[
property
].
options
,
value
:
requestBodyTemplate
[
property
]
});
}
}
}
...
...
@@ -87,31 +79,6 @@ var InstallService = function() {
return
configuration
;
};
this
.
_composeUrl
=
function
(
serverUrl
,
port
)
{
return
serverUrl
+
(
port
?
'
:
'
+
port
:
''
)
+
'
/api/v1/
'
;
};
this
.
_composeInstallUrl
=
function
(
installUrl
,
serviceId
,
apiKey
)
{
return
installUrl
+
'
/sid/
'
+
serviceId
+
'
/apiKey/
'
+
apiKey
;
};
// Gets API key as argv, i.e., "apiKey=somethingsomething"
this
.
_getApiKey
=
function
()
{
var
apiKey
=
''
;
if
(
process
.
argv
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
process
.
argv
.
length
;
i
++
)
{
var
arg
=
process
.
argv
[
i
];
var
s
=
'
apiKey
'
;
if
(
arg
.
indexOf
(
s
)
>
-
1
)
{
apiKey
=
arg
.
substring
(
s
.
length
+
1
);
}
}
}
return
apiKey
;
}
};
module
.
exports
=
new
InstallService
();
\ No newline at end of file
wrapper_configs/global.js
View file @
4058ad4f
...
...
@@ -6,7 +6,13 @@ config.redis = {
port
:
6379
};
config
.
serverUrl
=
'
http://dev.bitweb.ee
'
;
config
.
serverUrl
=
'
http://localhost
'
;
config
.
integration
=
{
installUrl
:
'
http://dev.bitweb.ee:8000/api/v1/service/install
'
,
apiKey
:
'
server-wrapper-api-key
'
};
config
.
fs
=
{
storagePath
:
"
/var/www/bitweb.ee/keeleliin.bitweb.ee/wrapper/tmp
"
,
...
...
@@ -29,10 +35,6 @@ config.wrapper = {
requestConf
:
null
};
config
.
integration
=
{
installUrl
:
'
http://localhost:3000/api/v1/service/install
'
};
config
.
log4js
=
{
appenders
:
[
{
...
...
@@ -120,13 +122,17 @@ var simpleCommandRequest = {
},
requestBodyParamsMappings
:
{
isAsync
:
{
type
:
'
select
'
,
options
:
[
'
0
'
,
'
1
'
],
usageType
:
config
.
paramUsageTypes
.
META
,
filter
:
function
(
value
)
{
filter
:
function
(
value
)
{
return
value
==
1
;
},
required
:
true
,
allowEmpty
:
false
,
validator
:
function
(
value
,
request
){
return
true
;
}
validator
:
function
(
value
,
request
)
{
return
true
;
}
}
/**
* , key: {
...
...
@@ -200,7 +206,8 @@ config.availableWrappers = {
port
:
3001
,
class
:
'
simpleLocalCommand
'
,
command
:
config
.
availableCommands
.
LAUSESTAJA
,
requestConf
:
simpleCommandRequest
requestConf
:
simpleCommandRequest
,
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
MORFANALYSAATOR
:
{
title
:
'
Morfoloogiline analüüs
'
,
...
...
@@ -209,7 +216,8 @@ config.availableWrappers = {
port
:
3002
,
class
:
'
simpleLocalCommand
'
,
command
:
config
.
availableCommands
.
MORFANALYSAATOR
,
requestConf
:
simpleCommandRequest
requestConf
:
simpleCommandRequest
,
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
OSALAUSESTAJA
:
{
title
:
'
Osalausestaja
'
,
...
...
@@ -218,7 +226,8 @@ config.availableWrappers = {
port
:
3003
,
class
:
'
simpleLocalCommand
'
,
command
:
config
.
availableCommands
.
OSALAUSESTAJA
,
requestConf
:
simpleCommandRequest
requestConf
:
simpleCommandRequest
,
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
MORFYHESTAJA
:
{
title
:
'
Morfoloogiline ühestamine (kitsenduste grammatika)
'
,
...
...
@@ -227,7 +236,8 @@ config.availableWrappers = {
port
:
3004
,
class
:
'
simpleLocalCommand
'
,
command
:
config
.
availableCommands
.
MORFYHESTAJA
,
requestConf
:
simpleCommandRequest
requestConf
:
simpleCommandRequest
,
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
PIND_SYN
:
{
title
:
'
Pindsüntaktiline analüüs
'
,
...
...
@@ -236,7 +246,8 @@ config.availableWrappers = {
port
:
3005
,
class
:
'
simpleLocalCommand
'
,
command
:
config
.
availableCommands
.
PIND_SYN
,
requestConf
:
simpleCommandRequest
requestConf
:
simpleCommandRequest
,
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
S6LT_SYN
:
{
title
:
'
Sõltuvussüntaktiline analüüs (ja järeltöötlus)
'
,
...
...
@@ -245,7 +256,8 @@ config.availableWrappers = {
port
:
3006
,
class
:
'
simpleLocalCommand
'
,
command
:
config
.
availableCommands
.
S6LT_SYN
,
requestConf
:
simpleCommandRequest
requestConf
:
simpleCommandRequest
,
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
ARCHIVE_EXTRACTOR
:
{
...
...
@@ -260,14 +272,17 @@ config.availableWrappers = {
},
requestBodyParamsMappings
:
{
isAsync
:
{
type
:
'
text
'
,
type
:
'
select
'
,
options
:
[
'
0
'
,
'
1
'
],
usageType
:
config
.
paramUsageTypes
.
META
,
filter
:
function
(
value
)
{
filter
:
function
(
value
)
{
return
value
==
1
;
},
required
:
true
,
allowEmpty
:
false
,
validator
:
function
(
value
,
request
){
return
true
;
}
validator
:
function
(
value
,
request
)
{
return
true
;
}
}
},
requestFiles
:
{
...
...
@@ -283,12 +298,7 @@ config.availableWrappers = {
isAsync
:
0
}
},
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}
]
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
TOKENIZER
:
{
title
:
'
Sõnestaja pipe
'
,
...
...
@@ -297,7 +307,8 @@ config.availableWrappers = {
port
:
3008
,
class
:
'
inputOutputLocalCommand
'
,
command
:
config
.
availableCommands
.
TOKENIZER
,
requestConf
:
simpleCommandRequest
requestConf
:
simpleCommandRequest
,
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
CONCAT
:
{
title
:
'
Lihtne konkateneerija
'
,
...
...
@@ -312,6 +323,8 @@ config.availableWrappers = {
},
requestBodyParamsMappings
:
{
isAsync
:
{
type
:
'
select
'
,
options
:
[
'
0
'
,
'
1
'
],
usageType
:
config
.
paramUsageTypes
.
META
,
filter
:
function
(
value
)
{
return
value
==
1
;
...
...
@@ -343,14 +356,9 @@ config.availableWrappers = {
staticParams
:
{
sessionMaxLifetime
:
600
,
isAsync
:
undefined
},
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}
]
}
}
},
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
},
MORPH_TAGGER
:
{
title
:
'
Morfoloogiline ühestaja pipe
'
,
...
...
@@ -358,7 +366,8 @@ config.availableWrappers = {
port
:
3010
,
class
:
'
inputOutputLocalCommand
'
,
command
:
config
.
availableCommands
.
MORPH_TAGGER
,
requestConf
:
simpleCommandRequest
requestConf
:
simpleCommandRequest
,
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}]
}
};
...
...
www/server.js
View file @
4058ad4f
...
...
@@ -24,6 +24,8 @@ var errorhandlerMiddleware = require('./../middlewares/errorhandler');
var
ServerUtil
=
require
(
'
./../src/util/server
'
);
var
cleanerService
=
require
(
'
./../src/service/cleanerService
'
);
var
installService
=
require
(
'
./../src/service/integration/installService
'
);
app
.
set
(
'
views
'
,
path
.
join
(
__base
,
'
views
'
));
// view engine setup
app
.
set
(
'
view engine
'
,
'
jade
'
);
// view engine setup
app
.
use
(
express
.
static
(
__base
+
'
/public
'
));
...
...
@@ -32,8 +34,15 @@ log4js.configure(config.log4js);
var
log4jsLogger
=
log4js
.
getLogger
(
'
wrapper_server_js
'
);
app
.
use
(
logger
(
'
dev
'
));
app
.
use
(
bodyParser
.
json
({
limit
:
'
1000mb
'
}));
// for parsing application/json
app
.
use
(
multer
({
dest
:
config
.
fs
.
tmpPath
}));
// for parsing multipart/form-data
app
.
use
(
bodyParser
.
json
({
limit
:
'
1mb
'
}));
// for parsing application/json
app
.
use
(
multer
({
dest
:
config
.
fs
.
tmpPath
,
/*limits: { fileSize: 1* 1024 * 1024}, //1mb
onFileUploadStart: function (file, req, res) {
console.error(file.fieldname + ' fileupload is starting ...', file);
}*/
}));
// for parsing multipart/form-data
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'
public
'
)));
app
.
use
(
routerMiddleware
.
routeLogger
);
app
.
use
(
controllers
);
...
...
@@ -67,6 +76,9 @@ function startCluster( instanceCount, cb ){
});
cleanerService
.
init
();
installService
.
install
(
function
()
{
log4jsLogger
.
error
(
'
Instal callback
'
);
})
}
else
{
startInstance
(
cb
)
}
...
...
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