GithubHelp home page GithubHelp logo

egorfine / node-reboot Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 4 KB

Reboot Linux from node.js without fork()ing /sbin/shutdown or going thru initscripts

License: Other

Python 7.98% JavaScript 31.44% C++ 60.57%

node-reboot's Introduction

node-reboot

Reboot Linux/macOS kernel immediately from node without calling /sbin/shutdown or going thru initscripts.

Why?

I'm running a cluster of Linux servers which boot readonly and perform a memory-intensive computations. node-reboot is a part of a watchdog application, which in case of emergencies much reboot the server immediately without fork()ing another process or going thru upstart/initscripts.

Synopsis

Call sync() and then reboot:

require('reboot').reboot();

Reboot without sync()ing:

require('reboot').rebootImmediately();

The function should never return. If it does, it means node has insufficient permissions.

Permissions (Linux only)

If you are to run node process under non-superuser, be sure to give node permissions to reboot the system:

sudo setcap CAP_SYS_BOOT=+ep /usr/local/bin/node

See man capabilities for details.

Installation

npm install reboot

or

npm install .

node-reboot's People

Contributors

egorfine avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ddresch

node-reboot's Issues

Cannot build in raspberry pi 2 with node 0.12

I have this error when trying to install the module:

 [email protected] install /home/pi/io-at-spot/io-at-spot/node_modules/reboot
> node-gyp rebuild

make: Entering directory '/home/pi/io-at-spot/io-at-spot/node_modules/reboot/build'
  CXX(target) Release/obj.target/reboot_bindings/src/reboot.o
../src/reboot.cc:12:40: error: 'Arguments' does not name a type
../src/reboot.cc:12:51: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
../src/reboot.cc: In function 'v8::Handle<v8::Value> _rebootImmediately(const int&)':
../src/reboot.cc:19:19: error: too few arguments to function 'v8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)'
/root/.node-gyp/0.12.6/deps/v8/include/v8.h:305:28: note: declared here
../src/reboot.cc: At global scope:
../src/reboot.cc:22:29: error: 'Arguments' does not name a type
../src/reboot.cc:22:40: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
../src/reboot.cc: In function 'v8::Handle<v8::Value> _reboot(const int&)':
../src/reboot.cc:31:19: error: too few arguments to function 'v8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)'
/root/.node-gyp/0.12.6/deps/v8/include/v8.h:305:28: note: declared here
../src/reboot.cc: In function 'void init(v8::Handle<v8::Object>)':
../src/reboot.cc:36:43: error: no matching function for call to 'NODE_SET_METHOD(v8::Handle<v8::Object>&, const char [7], v8::Handle<v8::Value> (&)(const int&))'
../src/reboot.cc:36:43: note: candidate is:
/root/.node-gyp/0.12.6/src/node.h:228:13: note: template<class TypeName> void node::NODE_SET_METHOD(const TypeName&, const char*, v8::FunctionCallback)
../src/reboot.cc:37:65: error: no matching function for call to 'NODE_SET_METHOD(v8::Handle<v8::Object>&, const char [18], v8::Handle<v8::Value> (&)(const int&))'
../src/reboot.cc:37:65: note: candidate is:
/root/.node-gyp/0.12.6/src/node.h:228:13: note: template<class TypeName> void node::NODE_SET_METHOD(const TypeName&, const char*, v8::FunctionCallback)
../src/reboot.cc: In function 'v8::Handle<v8::Value> _reboot(const int&)':
../src/reboot.cc:32:1: warning: control reaches end of non-void function [-Wreturn-type]
../src/reboot.cc: In function 'v8::Handle<v8::Value> _rebootImmediately(const int&)':
../src/reboot.cc:20:1: warning: control reaches end of non-void function [-Wreturn-type]
reboot_bindings.target.mk:83: recipe for target 'Release/obj.target/reboot_bindings/src/reboot.o' failed
make: *** [Release/obj.target/reboot_bindings/src/reboot.o] Error 1
make: Leaving directory '/home/pi/io-at-spot/io-at-spot/node_modules/reboot/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 3.18.11-v7+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/io-at-spot/io-at-spot/node_modules/reboot
gyp ERR! node -v v0.12.6
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok 
npm ERR! Linux 3.18.11-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "reboot"
npm ERR! node v0.12.6
npm ERR! npm  v2.11.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the reboot package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls reboot
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/io-at-spot/io-at-spot/npm-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.