demand

When you press Control + C to exit swift project running on VPS, your project has stopped, using server IP + port number access, has been unable to respond.

At this point, you need a Supervisor to keep your project running in the background so that your API is always accessible.

Basic configuration and description

Open the terminal and connect to the server. Create a folder to store your scripts. I put it in the Code folder and created a file called script.sh.

/root/Code/script.sh, where you need the supervisor to execute the script for you. And it’s always running in the background.

/root/code script.sh, which writes the path address and execution command.

cd /root/Code/PerfectTemplate
.build/debug/PerfectTemplate
Copy the code

Install and configure

Enter sudo apt-get install Supervisor to install supervisor.

After the installation is complete, go to CD /etc/supervisor/conf.d, create and edit vim SwiftServer. conf, swiftServer is my file name and program name.

Paste the following code into the file,

[Program :swiftServer] // swiftServer just named programcommandSh // Name of the script to run process_name=%(program_name)s directory=/root/Code // Directory of the script to run autorestart=trueUser =root // User nameCopy the code

For more Supervisor configuration information, please refer to the supervisor configuration information. This section only ensures that the project can be started normally.

The container is designed to be able to display the container on reload.

The container is running in the background when it is displayed

Open server IP :8181, Hello, world! Always with you.^.. ^