Skip to content

Commit

Permalink
changed env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kalisio-nicolas committed Jan 5, 2024
1 parent bdebdec commit 4526290
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ROLE=env.ROLE || console.error("ROLE not defined, exiting...") || process
const tmpdir = env.TMPDIR || "tmp"
const volumes = env.VOLUMES || "volumes"
const TTS = env.TTS || console.error("TTS not defined, process will run indefinitely")
const TimeZone = env.TimeZone || "Europe/Paris"
const TIMEZONE = env.TIMEZONE || "Europe/Paris"
const jobs = env.JOBS || 1


Expand All @@ -16,17 +16,17 @@ console.log("ROLE:", ROLE)
console.log("tmpdir:", tmpdir)
console.log("volumes:", volumes)
console.log("TTS:", TTS)
console.log("TimeZone:", TimeZone)
console.log("TIMEZONE:", TIMEZONE)
console.log("jobs:", jobs)

// Calculation of the time remaining before the stop time (TTS) its format is a string "HH:MM"
function get_time_to_stop(TTS, TimeZone) {
function get_time_to_stop(TTS, TIMEZONE) {
try {
// Get current date and time in the specified timezone
const now = DateTime.local().setZone(TimeZone);
// Get current date and time in the specified TIMEZONE
const now = DateTime.local().setZone(TIMEZONE);

// Get date and time for TTS in the specified timezone
let tts = DateTime.fromFormat(TTS, 'HH:mm', { zone: TimeZone });
// Get date and time for TTS in the specified TIMEZONE
let tts = DateTime.fromFormat(TTS, 'HH:mm', { zone: TIMEZONE });

// If tts is before now, add one day
if (tts < now) {
Expand Down Expand Up @@ -55,14 +55,14 @@ function stop () {

process.exit(0)
}
console.log("Process will stop in", get_time_to_stop(TTS, TimeZone)/60, "minutes")
console.log("Process will stop in", get_time_to_stop(TTS, TIMEZONE)/60, "minutes")

process.on('SIGTERM', stop);

if (env.TTS){
setTimeout(stop, get_time_to_stop(TTS, TimeZone)*1000)
setTimeout(stop, get_time_to_stop(TTS, TIMEZONE)*1000)
const interval=setInterval(() => {
console.log("Process will stop in", get_time_to_stop(TTS, TimeZone)/60, "minutes")
console.log("Process will stop in", get_time_to_stop(TTS, TIMEZONE)/60, "minutes")
}, 1000*60*5)

}
Expand Down
2 changes: 1 addition & 1 deletion src/worker_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const opts = program.opts()

var current_link = null
const ERR_CODES = {133: "Download failed", 134: "Extract failed", 135: "Transform failed", 136: "Upload failed"}
const hostname= env.BDORTHO_HOSTNAME || os.hostname()
const hostname= env.HOSTNAME || os.hostname()
const slack_url = process.env.BDORTHO_SLACK_URL || console.error("BDORTHO_SLACK_URL not defined")


Expand Down

0 comments on commit 4526290

Please sign in to comment.