Advertisement
amaksimov

mongo_import usage during container startup example

Mar 5th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. var fs = require('fs');
  2. if (fs.existsSync(path)) {
  3. let exec = require('child_process').exec
  4. let command = 'mongoimport -d database -c collection --file import.json'
  5. exec(command, (err, stdout, stderr) => {
  6. // check for errors or if it was succesfuly
  7. cb()
  8. })
  9. }
  10.  
  11. // Load the http module to create an http server.
  12. var http = require('http');
  13.  
  14. // Configure our HTTP server to respond with Hello World to all requests.
  15. var server = http.createServer(function (request, response) {
  16. response.writeHead(200, {"Content-Type": "text/plain"});
  17. response.end("Hello World\n");
  18. });
  19.  
  20. // Listen on port 8000, IP defaults to 127.0.0.1
  21. server.listen(8000);
  22.  
  23. // Put a friendly message on the terminal
  24. console.log("Server running at http://127.0.0.1:8000/");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement