我是否应该考虑在申请 bootstrap 期间阻塞 I/O 的不良做法? (node.js)

Should I consider a bad practice doing blocking I/O during the application bootstrap? (node.js)

假设我正在使用以下 伪代码:

引导一个简单的应用程序(即 node server.js
var http = require('http');
var path = require('path');
var fs = require('fs');

var router = require('function-that-handles-requests.js');
// ie, an express app

var routes = '/path/where/routes/are/stored';

fs.readdirSync( routes ).forEach(function( file ){
  var url = path.basename( file );
  var handler = require( path.resolve(routes, file) );

  router.useOrAddRouteOrWhatever( url, handler );

  // a real-world implementation should recurse sub-directories too
});

var server = http.createServer( router ).listen( /* ... */ );

我是否应该考虑这种阻塞的不良做法I/O?

不,绝对不是。服务器还没有启动。事实上,这是一种常见的做法。

(答案就是这么简单)