Power off: the Node used. js, mobile phone, and computer (work in OSX, Linux, and Windows) are created because I sometimes lie in bed to watch movies, and I want to remotely turn off my computer :)
Power off: the Node used. js, mobile phone, and computer (work in OS x, Linux, and Windows) create this project because I sometimes lie in bed to watch movies, and I want to remotely turn off my computer :) use 1. install stop-server
Npm install-g stop-serverstop-server start # start only once
2. Access http: // localhost: 5709/qr.html, scan the QR code, or directly access http: // your local-IP: 5709 on your mobile phone/tablet. You should be able to see this page: 3. Well, note: In OS X and Linux, You need to allow Shutdown Without the administrator password.
Command: # Run 'sudo mongodo 'and add
your-username ALL=NOPASSWD: /sbin/poweroff
The Stop-Server is a simple Express Server. When you call DELETE http: // your-local-ip: 5709, it runs poweroff (OS X, Linux) or shutdown (Windows ).
Note * shut down the code just a few lines: https://github.com/typicode/stop-server/blob/master/index.js
app.post('/', function (req, res) { var cmd = process.platform === 'win32' ? 'shutdown -s' : 'sudo --non-interactive poweroff' util.log('Running ' + cmd) cp.exec(cmd, function (err, stderr, stdout) { if (err) return res.status(500).json({ error: 'Can\'t run ' + cmd }) res.end() })})