1

I'm busy building a Web UI that can monitor certain apps on a number of machines via an RPC API.

I would like to implement functionality where the user can remotely reboot or shutdown the machine, I figured I would be able to create a 'client' app and expose an API which I can then send a reboot/shutdown command.

But I would like to stick to node.js for everything and create the client app in node.js as well.

Would this be possible using node?

2 Answers 2

2

require('child_process').exec('halt -p', console.log) will execute shutdown locally. Instead of "halt -p" you can use any command you want, including ssh 1.2.3.4 halt -p to run that remotely.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the heads up on child process, I looked through the entire docs but must have missed that, I've marked the answer above as the answer as it provides more functionality, but I will try this too!
1

Yes. There is a node-ssh client https://github.com/mscdex/ssh2 You can send shutdown -r now through that.

1 Comment

Thanks! That looks like a great module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.