UNPKG

next

Version:

The React Framework

77 lines (73 loc) 2.86 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "nextStart", { enumerable: true, get: function() { return nextStart; } }); const _startserver = require("../server/lib/start-server"); const _utils = require("../server/lib/utils"); const _getprojectdir = require("../lib/get-project-dir"); const _path = require("path"); const _constants = require("../shared/lib/constants"); const _config = /*#__PURE__*/ _interop_require_default(require("../server/config")); const _getvalidatedargs = require("../lib/get-validated-args"); function _interop_require_default(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const nextStart = async (argv)=>{ const validArgs = { // Types "--help": Boolean, "--port": Number, "--hostname": String, "--keepAliveTimeout": Number, // Aliases "-h": "--help", "-p": "--port", "-H": "--hostname" }; const args = (0, _getvalidatedargs.getValidatedArgs)(validArgs, argv); if (args["--help"]) { console.log(` Description Starts the application in production mode. The application should be compiled with \`next build\` first. Usage $ next start <dir> -p <port> <dir> represents the directory of the Next.js application. If no directory is provided, the current directory will be used. Options --port, -p A port number on which to start the application --hostname, -H Hostname on which to start the application (default: 0.0.0.0) --keepAliveTimeout Max milliseconds to wait before closing inactive connections --help, -h Displays this message `); process.exit(0); } const dir = (0, _getprojectdir.getProjectDir)(args._[0]); const host = args["--hostname"]; const port = (0, _utils.getPort)(args); const keepAliveTimeoutArg = args["--keepAliveTimeout"]; if (typeof keepAliveTimeoutArg !== "undefined" && (Number.isNaN(keepAliveTimeoutArg) || !Number.isFinite(keepAliveTimeoutArg) || keepAliveTimeoutArg < 0)) { (0, _utils.printAndExit)(`Invalid --keepAliveTimeout, expected a non negative number but received "${keepAliveTimeoutArg}"`, 1); } const keepAliveTimeout = keepAliveTimeoutArg ? Math.ceil(keepAliveTimeoutArg) : undefined; const config = await (0, _config.default)(_constants.PHASE_PRODUCTION_SERVER, (0, _path.resolve)(dir || "."), undefined, undefined, true); await (0, _startserver.startServer)({ dir, nextConfig: config, isDev: false, hostname: host, port, keepAliveTimeout, useWorkers: !!config.experimental.appDir }); }; //# sourceMappingURL=next-start.js.map