Stop-Server usage _ How to use a mobile phone to close your Linux Server

Source: Internet
Author: User
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()  })})

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.