Initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// variables
|
||||
const services = { start: {}, stop: {}, restart: {}, status: {} };
|
||||
const serviceNames = ['mysql','websocket','logger','scheduler'];
|
||||
|
||||
// dynamic manager
|
||||
['start', 'stop', 'status'].forEach(action => {
|
||||
serviceNames.forEach(name => {
|
||||
services[action][name] = async () => {
|
||||
const file = `./${name}/${action}.js`;
|
||||
const func = require(file);
|
||||
return await func();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// restart function
|
||||
serviceNames.forEach(name => {
|
||||
services.restart[name] = async () => {
|
||||
await services.stop[name]();
|
||||
await services.start[name]();
|
||||
};
|
||||
});
|
||||
|
||||
// function export
|
||||
module.exports = services;
|
||||
Reference in New Issue
Block a user