27 lines
696 B
JavaScript
27 lines
696 B
JavaScript
const config = require('./config.json')
|
|
const logger = require('./lib/logger')
|
|
const { spawn } = require('node:child_process')
|
|
|
|
const logger_runtime = new logger('./logs/runtime.log')
|
|
logger_runtime.log('start application')
|
|
|
|
function start_proc(path, args) {
|
|
// start app_proc
|
|
const app_proc = spawn(path, args, {
|
|
detached: true
|
|
})
|
|
app_proc.on('error', function(err) {
|
|
logger_runtime.error(err)
|
|
start_proc(path, args)
|
|
return
|
|
})
|
|
app_proc.on('close', (code) => {
|
|
logger_runtime.error('code: ', code)
|
|
start_proc(path, args)
|
|
return
|
|
})
|
|
}
|
|
config.applications.forEach(app => {
|
|
start_proc(app.path, app.args)
|
|
})
|