Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xpub-epmc
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Literature-services
public-projects
xpub-epmc
Commits
01245719
Commit
01245719
authored
3 years ago
by
Audrey Hamelers
Browse files
Options
Downloads
Patches
Plain Diff
#1185
parent
54e21ffc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!380
Pipeline changes
,
!379
Build step added for the master branch
,
!378
k8s release
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/ebi-integration/publishedCheck.js
+12
-7
12 additions, 7 deletions
server/ebi-integration/publishedCheck.js
server/job-runner/index.js
+22
-4
22 additions, 4 deletions
server/job-runner/index.js
with
34 additions
and
11 deletions
server/ebi-integration/publishedCheck.js
+
12
−
7
View file @
01245719
...
...
@@ -17,13 +17,18 @@ if (!process.env.ENABLE_CRONJOB_PUBLISHEDCHECK) {
}
;(
async
()
=>
{
await
checkJobStatus
(
'
published-check
'
,
async
()
=>
{
const
beforeUpdate
=
Date
.
now
()
await
publishedCheck
()
logger
.
info
(
`Published check was finished in
${
Date
.
now
()
-
beforeUpdate
}
ms`
,
)
})
await
checkJobStatus
(
'
published-check
'
,
async
()
=>
{
const
beforeUpdate
=
Date
.
now
()
await
publishedCheck
()
logger
.
info
(
`Published check was finished in
${
Date
.
now
()
-
beforeUpdate
}
ms`
,
)
},
// FTP healthcheck
true
,
)
await
NoteAccess
.
knex
().
destroy
()
process
.
exit
(
0
)
})()
...
...
This diff is collapsed.
Click to expand it.
server/job-runner/index.js
+
22
−
4
View file @
01245719
const
logger
=
require
(
'
@pubsweet/logger
'
)
const
superagent
=
require
(
'
superagent
'
)
const
config
=
require
(
'
config
'
)
const
{
parseExpression
}
=
require
(
'
cron-parser
'
)
const
{
JobManager
}
=
require
(
'
../xpub-model/
'
)
const
checkJobStatus
=
async
(
name
,
logic
)
=>
{
const
{
DATA_CENTER
}
=
process
.
env
const
{
internalBaseUrl
}
=
config
.
get
(
'
pubsweet-server
'
)
const
checkJobStatus
=
async
(
name
,
logic
,
ftp
)
=>
{
// Perform healthcheck
logger
.
info
(
`Running healthcheck`
)
const
url
=
`
${
internalBaseUrl
}
/healthcheck?datacenterName=
${
DATA_CENTER
}
&ftpExcluded=
${
ftp
?
0
:
1
}
`
try
{
await
superagent
.
get
(
url
)
}
catch
{
logger
.
info
(
'
Healthcheck failed. Exiting.
'
)
return
false
}
// Get job status from the database
logger
.
info
(
`Checking
${
name
}
status`
)
const
{
running
,
lastPass
,
frequency
}
=
await
JobManager
.
find
(
name
)
if
(
running
)
{
logger
.
info
(
`
${
name
}
is
currently runn
ing.`
)
logger
.
info
(
`
${
name
}
is
already running. Exit
ing.`
)
return
false
}
// Check if next pass exists between lastPass and current time
...
...
@@ -20,19 +37,20 @@ const checkJobStatus = async (name, logic) => {
await
interval
.
next
()
logger
.
info
(
`
${
name
}
scheduled. Running:`
)
}
catch
(
ignore
)
{
logger
.
info
(
`
${
name
}
not yet scheduled to run.`
)
logger
.
info
(
`
${
name
}
not yet scheduled to run.
Exiting.
`
)
return
false
}
// Mark job as running
await
JobManager
.
update
({
name
,
running
:
true
})
// Run job logic
let
status
=
'
fail
'
// Run job logic and update job table
try
{
await
logic
()
status
=
'
pass
'
}
catch
{
status
=
'
fail
'
}
// Update status when job completes (or fails)
return
JobManager
.
update
({
name
,
running
:
false
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment