Learn Sails.js - Part 9

von Manuel am 19.10.2025 um 12:00 Uhr

All preparations are complete. The crew is drilled, the ship is secure, and the holds are managed. But we are still anchored in a safe, familiar harbor. The time has come to chart a course for the open sea, the unpredictable, high-performance world of production.


Part 9: Charting the Open Seas (Configuration & Deployment)


The Captain’s Briefing (Background and Theory)

So far, we have operated in a private shipyard (localhost). Here, the waters are calm. Mistakes are cheap, our tools are laid out for us (sails lift auto-restarts the server), and performance isn’t a primary concern.

The open sea, a production environment, is different. It’s treacherous and demanding. Visitors expect a ship that is fast, efficient, and always available. We can’t have our First Mate on the deck constantly restarting the engine by hand. The ship must be configured to be lean, resilient, and ready for battle.

Environment-Specific Blueprints

Sails has a brilliant system for this: the config/env/ directory. Sails knows which environment it’s in based on a system-level flag called NODE_ENV.

This allows you to have completely different configurations for your shipyard and your sea voyages. Common differences include:

Launching the Fleet: The Dockmaster (PM2)

You don’t just run sails lift on a production server and walk away. What happens if the app crashes? Who restarts it? This is the job of a Process Manager.

A process manager is a dockmaster for your live application. The most popular one for Node.js apps is PM2. It’s a simple tool that you run your app with. It will:

The command to launch your ship for its maiden voyage will be sails lift --prod. The --prod flag is the crucial signal that tells Sails to enable all its production optimizations and use your production.js configuration file.


Key Concepts Checklist


Mission Log: Quest - “The Maiden Voyage Simulation”

We will prepare our ship for launch, configure its production-ready blueprints, and use a professional process manager to launch it, all safely on our local machine.


Mission Debrief (Review & Outcomes)

Land ho! The maiden voyage was a roaring success. You have successfully taken your application out of the development shipyard and prepared it for the rigors of the open ocean.

You now understand the critical difference between development and production environments and how to manage configurations for both. You have wielded a professional process manager, PM2, to launch, monitor, and control your application like a true fleet commander. While we only simulated this locally, these are the exact skills and commands you would use when deploying to a real server on a host like DigitalOcean or AWS.


Rewards & Promotion

Take the helm, Captain. You have proven your mastery of this vessel, from its initial construction to its final launch. There is only one challenge remaining: to command a fleet of your own.