Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xanadu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
SYNERG
xanadu
Commits
0ad5b02d
Commit
0ad5b02d
authored
Feb 12, 2020
by
Nilanjan Daw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
process deployment working
Added long running processes and deployment pipeline bypass support
parent
6438b7aa
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
34 deletions
+46
-34
dispatch_module/dispatch_daemon/execute.js
dispatch_module/dispatch_daemon/execute.js
+5
-3
dispatch_module/dispatch_daemon/index.js
dispatch_module/dispatch_daemon/index.js
+12
-11
dispatch_module/dispatcher/index.js
dispatch_module/dispatcher/index.js
+6
-1
dispatch_module/dispatcher/lib.js
dispatch_module/dispatcher/lib.js
+21
-17
dispatch_module/dispatcher/repository/worker_env/env.js
dispatch_module/dispatcher/repository/worker_env/env.js
+2
-2
No files found.
dispatch_module/dispatch_daemon/execute.js
View file @
0ad5b02d
...
...
@@ -28,17 +28,19 @@ function runIsolate(filename) {
}
function
runProcess
(
local_repository
,
functionHash
)
{
function
runProcess
(
local_repository
,
functionHash
,
port
)
{
let
filename
=
local_repository
+
functionHash
return
new
Promise
((
resolve
,
reject
)
=>
{
let
timeStart
=
Date
.
now
()
const
process
=
spawn
(
'
node
'
,
[
filename
]);
const
process
=
spawn
(
'
node
'
,
[
filename
,
port
]);
let
result
=
""
;
process
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stdout:
${
data
}
`
);
result
+=
data
;
let
timeDifference
=
Math
.
ceil
((
Date
.
now
()
-
timeStart
))
console
.
log
(
"
process time taken:
"
,
timeDifference
);
workerEvent
.
emit
(
'
start
'
,
functionHash
,
port
,
"
process
"
)
resolve
(
result
);
});
process
.
stderr
.
on
(
'
data
'
,
(
data
)
=>
{
...
...
@@ -48,7 +50,7 @@ function runProcess(local_repository, functionHash) {
process
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`child process exited with code
${
code
}
`
);
resolve
(
result
);
workerEvent
.
emit
(
'
end
'
,
port
,
"
process
"
);
});
})
...
...
dispatch_module/dispatch_daemon/index.js
View file @
0ad5b02d
...
...
@@ -70,17 +70,18 @@ function startWorker(local_repository, functionHash,function_id, producer, runti
}],
()
=>
{
})
})
else
if
(
runtime
===
"
process
"
)
execute
.
runProcess
(
local_repository
,
functionHash
,
port
).
then
(
result
=>
{
producer
.
send
(
[{
topic
:
"
response
"
,
messages
:
JSON
.
stringify
({
status
:
"
success
"
,
result
,
function_id
})
}],
()
=>
{
})
})
execute
.
runProcess
(
local_repository
,
functionHash
,
port
)
// .then(result => {
// producer.send(
// [{
// topic: "response",
// messages: JSON.stringify({
// status: "success",
// result,
// function_id
// })
// }], () => { })
// })
else
if
(
runtime
===
"
container
"
)
execute
.
runContainer
(
functionHash
,
port
)
// .then(result => {
...
...
dispatch_module/dispatcher/index.js
View file @
0ad5b02d
...
...
@@ -217,6 +217,7 @@ consumer.on('message', function (message) {
}
else
if
(
topic
==
"
deployed
"
)
{
message
=
JSON
.
parse
(
message
)
console
.
log
(
"
deployed
"
,
message
);
if
(
db
.
has
(
message
.
functionHash
+
message
.
runtime
))
{
let
{
req
,
res
}
=
db
.
get
(
message
.
functionHash
+
message
.
runtime
)
...
...
@@ -227,7 +228,11 @@ consumer.on('message', function (message) {
node_id
:
message
.
node_id
})
libSupport
.
reverseProxy
(
req
,
res
,
`http://
${
message
.
node_id
}
:
${
message
.
port
}
/serverless/function/execute`
)
libSupport
.
reverseProxy
(
req
,
res
,
`http://
${
message
.
node_id
}
:
${
message
.
port
}
/serverless/function/execute`
)
.
then
(()
=>
{
db
.
delete
(
message
.
functionHash
+
message
.
runtime
)
})
}
}
else
if
(
topic
==
"
removeWorker
"
)
{
console
.
log
(
"
removing metadata
"
,
message
);
...
...
dispatch_module/dispatcher/lib.js
View file @
0ad5b02d
...
...
@@ -28,6 +28,7 @@ function makeid(length) {
}
function
reverseProxy
(
req
,
res
,
url
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
"
requesting reverseproxy
"
);
var
options
=
{
...
...
@@ -41,11 +42,14 @@ function makeid(length) {
.
then
(
function
(
parsedBody
)
{
console
.
log
(
"
parsed body:
"
,
parsedBody
);
res
.
json
(
parsedBody
)
resolve
()
})
.
catch
(
function
(
err
)
{
console
.
log
(
"
error
"
,
err
.
message
);
res
.
json
(
err
.
message
).
status
(
err
.
statusCode
)
resolve
()
});
})
}
module
.
exports
.
makeid
=
makeid
;
...
...
dispatch_module/dispatcher/repository/worker_env/env.js
View file @
0ad5b02d
...
...
@@ -4,7 +4,7 @@ const bodyParser = require('body-parser')
const
app
=
express
()
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
app
.
use
(
bodyParser
.
json
())
let
port
=
5000
,
lastRequest
=
Date
.
now
()
let
port
=
(
process
.
argv
[
2
]
!=
null
)?
parseInt
(
process
.
argv
[
2
]):
5000
,
lastRequest
=
Date
.
now
()
app
.
post
(
'
/serverless/function/execute/
'
,
(
req
,
res
)
=>
{
let
payload
=
req
.
body
lastRequest
=
Date
.
now
()
...
...
@@ -22,7 +22,7 @@ app.listen(port, () => console.log(`Server listening on port ${port}!`))
function
shouldDie
()
{
if
(
Date
.
now
()
-
lastRequest
>
300
*
1000
)
{
if
(
Date
.
now
()
-
lastRequest
>
5
*
1000
)
{
console
.
log
(
"
Idle for too long. Exiting
"
);
process
.
exit
(
0
)
...
...
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