server.js 908 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * NodeJS-MVC 1.0
  3. * --------------------
  4. * HonorLee
  5. * http://honorlee.me
  6. * dev@honorlee.me
  7. */
  8. /*
  9. * Worker Process
  10. DO NOT CHANGE ANYTHING IN THIS FILE!
  11. */
  12. global.ROOTPATH = __dirname;
  13. require('./config.js');
  14. require('./system/core.js');
  15. let serverPort = 8000;
  16. try{
  17. require('http').createServer(serverHandler).listen(serverPort);
  18. LOGGER.info('Child Server start at port [' + serverPort + '] | ' + DateFormat('yyyy/MM/dd hh:mm:ss', new Date()));
  19. }catch(e){
  20. LOGGER.error('Child Server failed start at port [' + serverPort + '] | ' + DateFormat('yyyy/MM/dd hh:mm:ss', new Date()));
  21. }
  22. function serverHandler(req,res){
  23. if(req.method.toLowerCase()=='post'){
  24. let form = new Formidable.IncomingForm();
  25. form.parse(req, function(err, fields, files) {
  26. req._POST = fields;
  27. new ROUTER(req,res);
  28. });
  29. }else{
  30. new ROUTER(req,res);
  31. }
  32. }