Edit Page

FAQ

Can I use environment variables?

Yes! Like any Node app, your environment variables are available as process.env.

Sails also comes with built-in support for creating your own custom configuration settings that will be exposed directly on sails.config. And whether custom or built-in, any of the configuration properties in sails.config can be overridden using environment variables. See the conceptual documentation on Configuration for details.

Where do I put my production database credentials? Other settings?

The easiest way to add configuration to your Sails app is by modifying the files in config/ or adding new ones. Sails supports environment-specific configuration loading out of the box, so you can use config/env/production.js. Again, see the conceptual documentation on Configuration for details.

But sometimes you don't want to put certain configuration information into your repository. The best place to put this kind of configuration is in environment variables.

That said, for development (e.g. on your laptop) using environment variables can sometimes be cumbersome. So for your other deployment/machine-specific settings, namely any kind of credentials you want to keep private, you can also use your config/local.js file. This file is included in your .gitignore file by default, which helps prevent you from inadvertently commiting your credentials to your code repository.

config/local.js

// Local configuration
// 
// Included in the .gitignore by default,
// this is where you include configuration overrides for your local system
// or for a production deployment.
//
// For example, to use port 80 on the local machine, override the `port` config
module.exports = {
    port: 80,
    environment: 'production',
    adapters: {
        mysql: {
            user: 'root',
            password: '12345'
        }
    }
}

How do I get my Sails app on the server?

If you are using a Paas like Heroku or Modulus, it's easy: just follow their instructions!

Otherwise, get the IP address of your server and ssh onto it. Then npm install -g sails and npm install -g forever to install Sails and forever globally from NPM for the first time on the server. Finally git clone your project (or scp it onto the server if it's not in a git repo) into a new folder on the server, cd into it, and then run forever start app.js.

What should I expect as far as performance?

Baseline performance in Sails is comparable to what you'd expect from a standard Node.js/Express application. In other words, it's fast! We've done some optimizations ourselves in Sails core, but our primary focus is not messing up what we get for free from our dependencies. For a quick and dirty benchmark, see http://serdardogruyol.com/sails-vs-rails-a-quick-and-dirty-benchmark.

The most common performance bottleneck in production Sails applications is the database. Over the lifetime of an application with a growing user base, it becomes increasingly important to set up good indexes on your tables/collections and use queries which return paginated results. Eventually, as your production database grows to contain tens of millions of records, you will start to locate and optimize slow queries by hand (either by calling .query() or .native(), or by using the underlying database driver from NPM).

What's this warning about the connect session memory store?

If you are using sessions in your Sails app, you should not use the built-in memory store in production. The memory session store is a development-only tool that does not scale to multiple servers; even if you only have one server it is not particularly performant (see #3099 and #2779).

For instructions on configuring a production session store, see sails.config.session. If you want to disable session support altogether, turn off the session hook in your app's .sailsrc file:

"hooks": {
  "session": false
}

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Sails logo
  • Home
  • Get started
  • Support
  • Documentation
  • Documentation

For a better experience on sailsjs.com, update your browser.

Sailsconf 2022 June 22 - 24: Learn more at the Sailsconf website

Tweet Follow @sailsjs

Documentation

Reference Concepts App structure | Upgrading Contribution guide | Tutorials More

Concepts

  • Actions and controllers
    • Generating actions and controllers
    • Routing to actions
  • Assets
    • Default tasks
    • Disabling Grunt
    • Task automation
  • Blueprints
    • Blueprint actions
    • Blueprint routes
  • Configuration
    • The local.js file
    • Using `.sailsrc` files
  • Deployment
    • FAQ
    • Hosting
    • Scaling
  • E-commerce
  • Extending Sails
    • Adapters
      • Available adapters
      • Custom adapters
    • Custom responses
      • Adding a custom response
    • Generators
      • Available generators
      • Custom generators
    • Hooks
      • Available hooks
      • Events
      • Hook specification
        • .configure
        • .defaults
        • .initialize()
        • .registerActions()
        • .routes
      • Installable hooks
      • Project hooks
      • Using hooks
  • File uploads
    • Uploading to GridFS
    • Uploading to S3
  • Globals
    • Disabling globals
  • Helpers
    • Example helper
  • Internationalization
    • Locales
    • Translating dynamic content
  • Logging
    • Custom log messages
  • Middleware
    • Conventional defaults
  • Models and ORM
    • Associations
      • Many-to-many
      • One way association
      • One-to-many
      • One-to-one
      • Reflexive associations
      • Through associations
    • Attributes
    • Errors
    • Lifecycle callbacks
    • Model settings
    • Models
    • Query language
    • Records
    • Standalone Waterline usage
    • Validations
  • Policies
    • Access Control and Permissions
  • Programmatic usage
    • Tips and tricks
  • Realtime
    • Multi-server environments
    • On the client
    • On the server
  • Routes
    • Custom routes
    • URL slugs
  • Security
    • Clickjacking
    • Content security policy
    • CORS
    • CSRF
    • DDOS
    • P3P
    • Socket hijacking
    • Strict Transport Security
    • XSS
  • Services
  • Sessions
  • Shell scripts
  • Testing
  • Views
    • Layouts
    • Locals
    • Partials
    • View engines

Built with Love

The Sails framework is built by a web & mobile shop in Austin, TX, with the help of our contributors. We created Sails in 2012 to assist us on Node.js projects. Naturally we open-sourced it. We hope it makes your life a little bit easier!

Sails:
  • What is Sails?
  • Community
  • News
  • For business
About:
  • Our company
  • Security
  • Legal
  • Logos/artwork
Help:
  • Get started
  • Documentation
  • Docs
  • Contribute
  • Take a class

© 2012-2021 The Sails Company. 
The Sails framework is free and open-source under the MIT License. 
Illustrations by Edamame.