Skip to content

Install system services

Dave Lawrence edited this page Jul 5, 2021 · 9 revisions

This describes how to install VariantGrid on a server using services, a way for Unix to run programs all the time (ie not by a user logged in on a shell)

Install

Settings

In your settings files, be sure to set DEBUG=False. See Django docs why to never deploy a site into production with DEBUG turned on

NGINX

You will need to modify /etc/nginx/nginx.conf to work as a proxy.

There are 2 examples in the variantgrid/config dir. The one in the base directory runs on port 80 and handles static files. The one in variantgrid/config/variantgrid.com/nginx.conf uses a SSL certificate, and redirects http -> https.

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.ORIG
cp ${VARIANTGRID_DIR}/config/nginx.conf /etc/nginx/ # Or use variantgrid one for SSL example

Edit the newly copied file, you need to change at least 3 lines: the IP address, and the path to the static files eg:

server {
    listen   80;
    server_name 130.56.244.155;   # <---------------------------------- ** Change IP **
    add_header Access-Control-Allow-Origin 130.56.244.155; # <--------- ** Change IP **

    location /static/{
    autoindex on;
    root /opt/variantgrid/variantgrid/sitestatic; # <------------------ ** Change Path **
    }
}

If you're on a VM with a small root partition, change where NGINX puts temp upload files (remember to assign this write permission to the nginx user - which is probably "www-data"):

client_body_temp_path /mnt/nginx_upload_temp;

For the changes to take effect you'll need to have nginx reload the config file (simply restarting nginx will not have the same effect).

sudo nginx -s reload

Services

There are two types of services on Linux, Upstart and SystemD.

# Check which one you're using via:
ps -p1 | grep systemd && echo systemd || echo upstart

SystemD (Ubuntu >=15)

You need to edit the services, edit each service file in config/systemd/*.service so that

WorkingDirectory=/mnt/variantgrid # Needs to match ${VG_INSTALL_DIR}

then to install them

cp config/systemd/*.service /lib/systemd/system
for i in config/systemd/*.service;
    do systemctl enable $(basename ${i});
done;

# Then start them
./scripts/start_services.sh

If you have to change them once they've been installed, make sure to

sudo systemctl daemon-reload
./scripts/restart_services.sh

for the changes to be picked up

Mail Server

You can create users using the admin tool, or allow people to create their own accounts via the registration process, which requires an email server.

Instructions to Install PostFix mail server (requires a domain name)

Data Storage

A VM root partition is usually quite small, so we need to move data storage onto mounted disks

Clone this wiki locally