From 2895811f85a8aeb402a647a36de9d6b8f8d0721f Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 11 Jun 2020 11:40:03 +0200 Subject: [PATCH] Add crontab and systemd service in readme --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index b3e5042..36fae34 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,33 @@ # Writefreely stats Simple flask app to receive Writefreely blog stats as CSV and send them to InfluxDB +## Crontask + +Send your stats every 10 minutes: + +``` +*/10 * * * * sqlite3 /srv/writefreely/writefreely.db ".mode csv" ".header on" "select id, slug, view_count, title from posts order by view_count desc;" | curl -X POST -H "Content-Type: text/csv" -m 30 --data-binary @- "http://:/stats" +``` + +## systemd service + +``` +# /etc/systemd/system/blog_stats.service + +[Unit] +Description=Blog stats +After=network-online.target influxdb.service + +[Service] +Type=simple +User=pi +WorkingDirectory=/home/pi/blog_stats +ExecStart=/home/pi/blog_stats/.venv/bin/uwsgi --http [::]: --wsgi-file main.py --callable app +Environment="INFLUX_USER=" +Environment="INFLUX_PASSWORD=" +Environment="INFLUX_DB=" + +[Install] +WantedBy=multi-user.target +``` +