Run Multiple UserVMs

Revision as of 09:14, 26 July 2024 by 6eamed (talk | contribs) (Page created.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Preparing the VM directories

To start, ensure your directory structure is set up as follows:

/srv/collabvm/vms
/srv/collabvm/vms/vm1
/srv/collabvm/vms/vm1/config.toml
/srv/collabvm/vms/vm2
/srv/collabvm/vms/vm2/config.toml

Creating and starting the service

Firstly, delete your current CollabVM service. Next, create a template service. You can put the following configuration into /etc/systemd/system/[email protected]

[Unit]
Description=CollabVM VM %i

[Service]
User=collabvm
Group=collabvm
Restart=always
RestartSec=5
Type=simple
WorkingDirectory=/srv/collabvm/vms/%i

Environment=NODE_ENV=production
ExecStart=/bin/node /srv/collabvm/collabvm-1.2.ts/build/index.js #Ensure your server is located at this path

[Install]
WantedBy=multi-user.target

After saving, reload systemd:

sudo systemctl daemon-reload

If everything has been done correctly, you should be able to start your VMs using:

sudo systemctl enable collabvm@vm1
sudo systemctl enable collabvm@vm2
sudo systemctl start collabvm@vm1
sudo systemctl start collabvm@vm2

Final configuration

Ensure that the port and vncPort for each VM differ from each other. Additionally, make sure each node has a unique name.

Finally, add the following location blocks to your nginx configuration file:

location /collab-vm/vm1 {
    include wsproxy_params;
    proxy_pass http://127.0.0.1:6004/; 
}

location /collab-vm/vm2 {
    include wsproxy_params;
    proxy_pass http://127.0.0.1:6005/; 
}

Please be sure to restart nginx after this step:

sudo systemctl restart nginx