Skip to content

Instantly share code, notes, and snippets.

@MitsuhaMiyamizu
Forked from noreply-builder/webvirtmgr.md
Created November 16, 2016 04:32
Show Gist options
  • Save MitsuhaMiyamizu/ff2d7b82a99c75b381e1401c8a3ab0d5 to your computer and use it in GitHub Desktop.
Save MitsuhaMiyamizu/ff2d7b82a99c75b381e1401c8a3ab0d5 to your computer and use it in GitHub Desktop.
webvirtmgr systemd service example

10. 恢复 kvm web 管理面板

pacman -S python-virtualenv
cd /var/www/webvirtmgr

source venv/bin/activate

运行测试

python /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
python /var/www/webvirtmgr/console/webvirtmgr-console -d

确保没有报错。

新建 systemd 服务

vi /etc/systemd/system/webvirtmgr.service

[Unit]
Description=Webvirtmgr service 
After=network.target

[Service]
ExecStart=/var/www/webvirtmgr/venv/bin/python /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
Restart=always

[Install]
WantedBy=multi-user.target

vi /etc/systemd/system/webvirtmgr-console.service

[Unit]
Description=Webvirtmgr console service 
After=network.target

[Service]
ExecStart=/var/www/webvirtmgr/venv/bin/python /var/www/webvirtmgr/console/webvirtmgr-console -d
Restart=always

[Install]
WantedBy=multi-user.target
systemctl enable webvirtmgr
systemctl start webvirtmgr

systemctl enable webvirtmgr-console
systemctl start webvirtmgr-console

恢复 webvirtcloud

cd /var/www/webvirtcloud
source venv/bin/activate

运行测试,确保正确执行

/var/www/webvirtcloud/venv/bin/gunicorn webvirtcloud.wsgi:application -c /var/www/webvirtcloud/gunicorn.conf.py
/var/www/webvirtcloud/venv/bin/python /var/www/webvirtcloud/console/novncd

添加 systemd 服务

vi /etc/systemd/system/webvirtcloud.service

[Unit]
Description=Webvirtcloud service 
After=network.target

[Service]
WorkingDirectory=/var/www/webvirtcloud/
ExecStart=/var/www/webvirtcloud/venv/bin/gunicorn webvirtcloud.wsgi:application -c /var/www/webvirtcloud/gunicorn.conf.py
Restart=always

[Install]
WantedBy=multi-user.target

vi /etc/systemd/system/webvirtcloud-novncd.service

[Unit]
Description=Webvirtcloud novncd service 
After=network.target

[Service]
ExecStart=/var/www/webvirtcloud/venv/bin/python /var/www/webvirtcloud/console/novncd
Restart=always

[Install]
WantedBy=multi-user.target
systemctl enable webvirtcloud
systemctl start webvirtcloud

systemctl enable webvirtcloud-novncd
systemctl start webvirtcloud-novncd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment