Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetaGer Keymanager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer Keymanager
Commits
feac50a4
Commit
feac50a4
authored
2 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
accent cli configurable and synced by cronjob
parent
11790826
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#7325
passed
2 years ago
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
pass/bin/cron
+38
-0
38 additions, 0 deletions
pass/bin/cron
pass/config/default.json
+13
-0
13 additions, 0 deletions
pass/config/default.json
with
53 additions
and
1 deletion
.gitignore
+
2
−
1
View file @
feac50a4
pass/config/development.json
pass/config/production.json
\ No newline at end of file
pass/config/production.json
pass/accent.json
This diff is collapsed.
Click to expand it.
pass/bin/cron
+
38
−
0
View file @
feac50a4
const
dayjs
=
require
(
"dayjs"
);
const
Order
=
require
(
"../app/Order"
);
const
RedisClient
=
require
(
"../app/RedisClient"
);
const
config
=
require
(
"config"
);
const
path
=
require
(
"path"
);
const
{
writeFileSync
}
=
require
(
"fs"
);
const
{
exec
}
=
require
(
"child_process"
);
let
redis_client
;
/**
* Will call every cron script every minute.
...
...
@@ -21,13 +25,47 @@ let cronjobs = async () => {
"YYYY-MM-DD HH:mm:ss"
)}] Written ${written_logs} key changes.`
);
await
accentSync
();
await
redis_client
.
quit
();
console
.
log
(
`[${now.format("YYYY-MM-DD HH:mm:ss")}] Finish`
);
};
console
.
log
(
"Start"
);
let
interval
=
setInterval
(
cronjobs
,
60000
);
init
();
cronjobs
();
function
init
()
{
if
(
process
.
env
.
NODE_ENV
===
"development"
&&
config
.
get
(
"app.accent.apiKey"
)
.
length
>
0
)
{
let
accent_config
=
config
.
get
(
"app.accent"
);
writeFileSync
(
path
.
join
(
__dirname
,
".."
,
"accent.json"
),
JSON
.
stringify
(
accent_config
,
null
,
4
));
}
}
async
function
accentSync
()
{
if
(
process
.
env
.
NODE_ENV
!==
"development"
)
{
return
;
}
return
new
Promise
((
resolve
)
=>
{
exec
(
"accent sync"
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
console
.
error
(
error
);
}
if
(
stderr
)
{
console
.
error
(
stderr
);
}
console
.
log
(
stdout
);
let
now
=
dayjs
();
console
.
log
(
`[${now.format(
"YYYY-MM-DD HH:mm:ss"
)}] Synced language files.`
);
resolve
();
});
})
}
async
function
writeLogsToOrder
()
{
let
redis_lock_key
=
"cron:writeLogsToOrder"
;
let
interval_seconds
=
60
;
// Will execute every minute
...
...
This diff is collapsed.
Click to expand it.
pass/config/default.json
+
13
−
0
View file @
feac50a4
...
...
@@ -18,6 +18,19 @@
"enabled"
:
true
,
"url"
:
"<OSTICKET_URL>"
,
"api_key"
:
"<OSTICKET_API_KEY>"
},
"accent"
:
{
"apiUrl"
:
"https://translate.metager.de"
,
"apiKey"
:
""
,
"files"
:
[
{
"language"
:
"de"
,
"format"
:
"json"
,
"source"
:
"lang/de/*.json"
,
"target"
:
"lang/%slug%/%original_file_name%.json"
,
"hooks"
:
{}
}
]
}
},
"price"
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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