Skip to main content
For production environments, psys can run as a background process with no terminal output, making it ideal for continuous monitoring.

Background Process Mode

The start:bg script runs psys as a detached background process that continues running even after closing your terminal.
1

Build the production bundle

Build the application at least once before starting in background mode:
npm run build
This creates an optimized production build using next build.
2

Start the background server

npm run start:bg
This runs the command:
nohup next start -p 30999 > /dev/null 2>&1 &
3

Access the application

Open http://localhost:30999 in your browser.The app continues running in the background on port 30999.

Background Script Breakdown

The start:bg script uses several techniques to run as a background process:
nohup next start -p 30999 > /dev/null 2>&1 &
ComponentPurpose
nohupPrevents the process from being terminated when the terminal closes
next startStarts the Next.js production server
-p 30999Runs on port 30999 instead of the default 3000
> /dev/nullRedirects standard output to null (no terminal output)
2>&1Redirects standard error to standard output (also suppressed)
&Runs the command in the background
With this configuration, the server produces no terminal output. To monitor the application, access it through the web interface or check system logs.

When to Use Each Mode

Development Mode

Use npm run dev when:
  • Developing new features
  • Testing changes with hot reload
  • Debugging issues
  • Need detailed error messages

Production Mode

Use npm start when:
  • Running in production
  • Need optimized performance
  • Want to test production build locally
  • Terminal needs to stay open

Background Mode

Use npm run start:bg when:
  • Running continuously in production
  • Want to close the terminal
  • Need a dedicated monitoring port
  • Running as a system service

Never Use

Don’t use npm run dev in production:
  • Slower performance
  • Larger memory footprint
  • Security implications
  • Not optimized for production workloads

Stopping the Background Process

To stop a background process started with npm run start:bg:
1

Find the process ID

ps aux | grep "next start"
2

Kill the process

kill <PID>
Replace <PID> with the process ID from the previous step.
For easier process management, consider setting up a shell alias to start and stop psys with simple commands.