Add NodeStart.js and NodeStop.js

This commit is contained in:
Alex Thomas 2020-03-21 20:14:42 -04:00
parent 72166d170b
commit 6e1944a872
4 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,13 @@
module.exports.typeDefs = `
type NodeActions {
start: EmptyOutput!
}
`;
module.exports.resolvers = {
NodeActions: {
start (root, args, { dispatch }) {
return dispatch('api/node/start');
}
}
};

View File

@ -0,0 +1,13 @@
module.exports.typeDefs = `
type NodeActions {
stop: EmptyOutput!
}
`;
module.exports.resolvers = {
NodeActions: {
stop (root, args, { dispatch }) {
return dispatch('api/node/stop');
}
}
};

View File

@ -0,0 +1,8 @@
const { exec } = require('child_process')
module.exports = ({ define }) => {
define('start', async (payload, { knex, errors, utils }) => {
exec('sudo systemctl start node')
},
{ auth: true })
}

View File

@ -0,0 +1,8 @@
const { exec } = require('child_process')
module.exports = ({ define }) => {
define('stop', async (payload, { knex, errors, utils }) => {
exec('sudo systemctl stop node')
},
{ auth: true })
}