Yann Weber c63732b5a3 Initial commit | 3 years ago | |
---|---|---|
pyws_clock | 3 years ago | |
.gitignore | 3 years ago | |
README.md | 3 years ago | |
config.ini.inc | 3 years ago | |
logrotate_pyws_clock.inc | 3 years ago | |
nginx_server.conf | 3 years ago | |
pyws_clock.service.inc | 3 years ago | |
requirements.txt | 3 years ago | |
run_server.sh | 3 years ago |
Websocket clock server, handling timezones and alarms.
Debian-based dependencies installation
apt install python3-dateutil python3-websockets
Installing dependencies using pip
pip3 install -r requirements.txt
python3 -m pyws_clock
Get some help using python3 -m pyws_clock --help
Systemd service will run the server using the run_server.sh
script. This
script runs python3 -m pyws_clock -C config.ini
allowing to configure the
daemon with a config.ini
file.
cp config.ini.inc config.ini; edit config.ini
cp pyws_clock.service.inc pyws_clock.service
edit pyws_clock.service
cp pyws_clock.service /etc/systemd/system/
systemctl enable pyws_clock.service
systemctl start pyws_clock.service
systemctl status pyws_clock.service
Run this command and send a dummy session id by pressing enter.
python3 -m websockets ws://127.0.0.1:8901
adduser --system pyws_clock
cp -R pyws_clock /home/pyws_clock/
cd /home/pyws_clock/pyws_clock/
cp config.ini.inc config.ini
echo "session_directory=/var/run/pyws_clock/sessions/
logfile=/var/log/pyws_clock/pyws_clock.log" >> config.ini
cp pyws_clock.service.inc pyws_clock.service
echo -e "User=pyws_clock
Group=nogroup
WorkingDirectory=/home/pyws_clock/pyws_clock/
ExecStart=/home/pyws_clock/pyws_clock/run_server.sh" >> pyws_clock.service
mv pyws_clock.service /etc/systemd/system/
# log dir & rotation config
mkdir /var/log/pyws_clock/
chown pyws_clock: /var/log/pyws_clock
cp logrotate_pyws_clock.inc /etc/logrotate.d/pyws_clock
systemctl restart logrotate
# session directory creation
mkdir -p /var/run/pyws_clock/sessions/
chown -R pyws_clock: /var/run/pyws_clock
# Enabling & starting the systemd service
systemctl enable pyws_clock.service
systemctl start pyws_clock.service
systemctl status pyws_clock.service
A sample configuration is available in nginx_server.conf
.