Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
71aa0c93
Unverified
Commit
71aa0c93
authored
Apr 12, 2021
by
LK HO
Committed by
GitHub
Apr 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: jobs/worker - pass through job error from worker process (#3822)
parent
a20f70ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
5 deletions
+22
-5
scheduler.js
server/core/scheduler.js
+11
-3
worker.js
server/core/worker.js
+7
-2
rebuild-tree.js
server/jobs/rebuild-tree.js
+2
-0
render-page.js
server/jobs/render-page.js
+2
-0
No files found.
server/core/scheduler.js
View file @
71aa0c93
...
...
@@ -55,14 +55,22 @@ class Job {
`--job=
${
this
.
name
}
`
,
`--data=
${
data
}
`
],
{
cwd
:
WIKI
.
ROOTPATH
cwd
:
WIKI
.
ROOTPATH
,
stdio
:
[
'inherit'
,
'inherit'
,
'pipe'
,
'ipc'
]
})
const
stderr
=
[];
proc
.
stderr
.
on
(
'data'
,
chunk
=>
stderr
.
push
(
chunk
))
this
.
finished
=
new
Promise
((
resolve
,
reject
)
=>
{
proc
.
on
(
'exit'
,
(
code
,
signal
)
=>
{
const
data
=
Buffer
.
concat
(
stderr
).
toString
()
if
(
code
===
0
)
{
resolve
()
resolve
(
data
)
}
else
{
reject
(
signal
)
const
err
=
new
Error
(
`Error when running job
${
this
.
name
}
:
${
data
}
`
)
err
.
exitSignal
=
signal
err
.
exitCode
=
code
err
.
stderr
=
data
reject
(
err
)
}
proc
.
kill
()
})
...
...
server/core/worker.js
View file @
71aa0c93
...
...
@@ -14,6 +14,11 @@ WIKI.logger = require('./logger').init('JOB')
const
args
=
require
(
'yargs'
).
argv
;(
async
()
=>
{
await
require
(
`../jobs/
${
args
.
job
}
`
)(
args
.
data
)
process
.
exit
(
0
)
try
{
await
require
(
`../jobs/
${
args
.
job
}
`
)(
args
.
data
)
process
.
exit
(
0
)
}
catch
(
e
)
{
await
new
Promise
(
resolve
=>
process
.
stderr
.
write
(
e
.
message
,
resolve
))
process
.
exit
(
1
)
}
})()
server/jobs/rebuild-tree.js
View file @
71aa0c93
...
...
@@ -74,5 +74,7 @@ module.exports = async (pageId) => {
}
catch
(
err
)
{
WIKI
.
logger
.
error
(
`Rebuilding page tree: [ FAILED ]`
)
WIKI
.
logger
.
error
(
err
.
message
)
// exit process with error code
throw
err
}
}
server/jobs/render-page.js
View file @
71aa0c93
...
...
@@ -90,5 +90,7 @@ module.exports = async (pageId) => {
}
catch
(
err
)
{
WIKI
.
logger
.
error
(
`Rendering page ID
${
pageId
}
: [ FAILED ]`
)
WIKI
.
logger
.
error
(
err
.
message
)
// exit process with error code
throw
err
}
}
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