This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ===== virtualenv service in systemd ===== Create a unit file: <code> sudo vim /etc/systemd/system/rapidsms.service </code> With this content (you may need change it): <code> [Unit] Description=RapidSMS Virtualenv service After=network.target [Service] User=emonge Group=emonge Environment=VIRTUAL_ENV=/home/emonge/smsbot-venv Environment=PATH=$VIRTUAL_ENV/bin:$PATH ExecStart=/bin/bash -c "cd /home/emonge/smsbot; $VIRTUAL_ENV/bin/python manage.py runserver 192.168.1.12:8000" Restart=always [Install] WantedBy=multi-user.target </code> Make it executable: <code> sudo chmod 644 /lib/systemd/system/rapidsms.service </code> Reload systemd service: <code> sudo systemctl daemon-reload </code> Enable service to start during boot secuence: <code> sudo systemctl enable rapidsms.service </code> ==== Log file ==== Modify the line starting with ExecStart in file /lib/systemd/system/rapidsms.service to: <code> ExecStart=/bin/bash -c "cd /home/emonge/smsbot; $VIRTUAL_ENV/bin/python manage.py runserver 192.168.1.12:8000 > /home/emonge/smsbot/smsbot.log 2>&1" </code> ==== References ==== * http://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/ * https://blog.philippklaus.de/2013/03/start-a-python-tool-or-web-app-that-uses-virtualenv-on-system-startup-using-systemd/ * https://gist.github.com/danechitoaie/f2bb03fd0c2d6b803878