Supervisor is a process control system that makes it easy to start, stop, and restart your Vapor app.
sudo apt-get update sudo apt-get install supervisor
Each Vapor app on your server should have its own configuration file. For an example
Hello project, the configuration file would be located at
[program:hello] command=/home/vapor/hello/.build/release/Run serve --env production directory=/home/vapor/hello/ user=vapor stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log
As specified in our configuration file the
Hello project is located in the home folder for the user
vapor. Make sure
directory points to the root directory of your project where the
Package.swift file is.
--env production flag will disable verbose logging.
You can export variables to your Vapor app with supervisor.
Exported variables can be used in Vapor using
let port = Environment.get("PORT")
You can now load and start your app.
supervisorctl reread supervisorctl add hello supervisorctl start hello
add command may have already started your app.