- Version: 0.0.5
- Last changes timestamp: 2022.02.24, 00:55
- Last changes timetag: 220224-0055
Basic api structure:
TODO: Describe api (for specific server version)
Remote server: http://cam-rpi-server.lilliputten.ru/
Images server runs on python/flask platform.
TODO: Describe basic server functionality.
TODO: Preserve capability to implement public server (with same or like functinal?)
Server command for creating venv:
virtualenv -p python3 ~/.venv-py3-flask
source ~/.venv-py3-flask/bin/activate
pip install -r requirements.txt
Local script for venv creating and initialization:
sh utils/util-venv-init.sh
Local command for activate venv:
call .venv/Scripts/activate
source .venv/Scripts/activate
pip install PKGNAME
pip freeze > requirements-frozen.txt
pip install -r requirements.txt
Camera shots are taken using the raspistill
program using commands like:
# Default:
raspistill -o image.jpg
# Half:
raspistill -w 1296 -h 972 -o image-half.jpg
# Quarter:
raspistill -w 648 -h 486 -o image-quarter.jpg
For commandline reference use raspistill --help
.
Use client-make-and-upload-image.sh
script to make & upload image to server.
Use crontab to automate image capture.
- Every minute:
* * * * * /home/pi/projects/cam-rpi-server/client-make-and-upload-image.sh
- Every 15th minute:
*/15 * * * * /home/pi/projects/cam-rpi-server/client-make-and-upload-image.sh
# Test entry...
30 */1 * * * date >> ~/test_crontab
*/5 * * * * date >> ~/test_crontab
# Make & upload shots every 5 minutes (with forced logging)...
*/5 * * * * sh /home/pi/projects/cam-rpi-server/client-make-and-upload-image.sh >> /home/pi/projects/cam-rpi-server/cron-log.txt 2>&1
# Make & upload shots every 20 minutes...
*/20 * * * * sh /home/pi/projects/cam-rpi-server/client-make-and-upload-image.sh
# Reboot every 3 hours (00:55, 03:55, etc...)
55 */3 * * * sudo reboot -f
# Start server on boot
@reboot sh /home/pi/projects/cam-rpi-server/utils/rpi-start-server.sh
Edit crontab:
crontab -e
Show crontab:
crontab -l
Automatically add server start command to crontab with:
sh utils/rpi-gunicorn-server-create-crontab-entry.sh
See also:
Uncomment # cron.*
line in /etc/rsyslog.conf
(eg. edit with sudo vim /etc/rsyslog.conf
).
Show crontab log:
tail -f /var/log/cron.log
Or use output reirect in command:
/home/pi/cam-rpi-server/client-make-and-upload-image.sh >> /home/pi/cam-rpi-server/cron.log 2>&1
python /home/pi/cam-client/client-make-image.py >> /home/pi/projects/cam-rpi-server/cron.log 2>&1
- Beginners guide to install a Flask (Python) web server on Raspberry PI
- Running Gunicorn โ Gunicorn 20.1.0 documentation
gunicorn -w 1 -b 0.0.0.0:4000 hello:app
Real command (see utils/rpi-start-server.sh
, attention for port number, in -b
switch):
&& "$GUNICORN" \
--reload \
-D \
-w 1 \
-b 0.0.0.0:4000 \
--chdir "$ROOT" \
--pid="$PIDFILE" \
--log-file="$LOGFILE" \
index \
&& echo "Done." \
See log-gunicorn.log
and log-gunicorn.pid
files in project root folder after start.
For autostart see 'crontab' section above.