Create a unit file:
sudo vim /etc/systemd/system/rapidsms.service
With this content (you may need change it):
[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
Make it executable:
sudo chmod 644 /lib/systemd/system/rapidsms.service
Reload systemd service:
sudo systemctl daemon-reload
Enable service to start during boot secuence:
sudo systemctl enable rapidsms.service
Modify the line starting with ExecStart in file /lib/systemd/system/rapidsms.service to:
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"