File size: 1,016 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#!/usr/bin/env node
import '../server/lib/cpu-profile'
import { startServer } from '../server/lib/start-server'
import { printAndExit } from '../server/lib/utils'
import { getProjectDir } from '../lib/get-project-dir'
import {
getReservedPortExplanation,
isPortIsReserved,
} from '../lib/helpers/get-reserved-port'
export type NextStartOptions = {
port: number
hostname?: string
keepAliveTimeout?: number
}
/**
* Start the Next.js server
*
* @param options The options for the start command
* @param directory The directory to start the server in
*/
const nextStart = async (options: NextStartOptions, directory?: string) => {
const dir = getProjectDir(directory)
const hostname = options.hostname
const port = options.port
const keepAliveTimeout = options.keepAliveTimeout
if (isPortIsReserved(port)) {
printAndExit(getReservedPortExplanation(port), 1)
}
await startServer({
dir,
isDev: false,
hostname,
port,
keepAliveTimeout,
})
}
export { nextStart }
|