This guide for the redhen server (depends on paths and environment).
- Download the latest
unav-recordingmonitor-bundle-x.x.x.tgz
from GitHub Releases - Extract to the
/home/redhen/recordingmonitor
- Add the following line to crontab (why use exec):
*/15 * * * * root exec /bin/bash /home/redhen/recordingmonitor/scripts/public/start.sh
- DONE!
cron
will ensure that app is running (and start it when necessary) every
15 minutes. cron
restart is not required.
It it a rough file-tree structure (correct for version 0.1.3):
/home/redhen/
├── recordingmonitor
│ ├── recordingmonitor // yes, it's recordingmonitor in recordingmonitor
│ │ │
│ │ ├── array.so // \
│ │ ├── base_library.zip // \
│ │ ├── xxxxxxxx.so // * - 3d-party libraries
│ │ ├── ........... // /
│ │ ├── binascii.so // /
│ │ │
│ │ ├── recordingmonitor // MAIN BINARY (recordingmonitor again)
│ │ ├── unav // UI and other app dependencies
│ │ │
│ │ └── scripts // \
│ │ └── public // \
│ │ ├── channels-create.sh // * - script helpers
│ │ └── start.sh // /
│ │
│ ├── log // log files
│ │ └── recordingmonitor.log
│ │
│ ├── recordingmonitor.sqlite // DB
│ ├── recordingmonitor.yml // config file
│ │
│ └── tmp // working directory, with capturing results
│ └── maintenance
│
│
├── unav-recordingmonitor-bundle-0.1.3.dev0.tgz // - original package
│
└── software // \
├── ccextractor // * - external utilities
├── multicat // /
└── ...
- download package
unav-recordingmonitor-0.0.1.tar.gz
(use the latest version, plz) - install
pip install unav-recordingmonitor-0.0.1.tar.gz
- run
RecordingMonitor
ORpython3 -m unav.recordingmonitor
- open http://127.0.0.1:9000 in your browser
Script will automatically create its DB (internal storage) --
recordingmonitor.sqlite
OBSOLETE
First, you need to get an image (it is private). You could download it (not implemented yet) or build (see development section of this guide)
Having image locally you can run a container:
docker run --rm --name mon unav/recordingmonitor`
Some settings can be set through environment variables. But it is possible to mount configuration file from host machine.
Time zone could be set in the configuration property scheduler.tz
with
fallback to 'UTC'
time zone.
Applicable values are described in the documentation for PyTZ module:
Create virtualenv (run once):
virtualenv env/recordingmonitor
Enable virtualenv:
source env/recordingmonitor/bin/activate
Install dev-dependencies:
pip install -r requirements-dev.txt
Modify:
- Create a branch:
git checkout -b dev/my-feature
- Edit files
- Commit changes:
git commit -m 'config: my changes'
- Lint:
python -m flake8
- Test:
python -m pytest
Send to upstream:
- Rebase (to keep history clean):
git rebase upstream/master
- Push to your fork:
git push origin
- Create PULL REQUEST and wait for acceptance!
Client UI is a Vue-application (javascript framework).
To rebuild client UI you will need:
- Install Node.JS (version >= 4.0.0)
- go to sources (
cd client
) and install dependencies:npm install
It is very useful to connect Python and JS parts by linking Vue-app as a static asset:
# run from the root folder of the local git-repo
ln -r -s ./client/dist ./unav/recordingmonitor/web/ui/dist
To create new package run:
python setup.py sdist
The result -- unav-recordingmonitor-X.Y.Z.tar.gz
file in the /dist
folder.
To create a new version of a pre-built bundle you will need a Docker image for building. For the first time you could create it (locally) with this command:
cd docker/pack-centos6
docker build -f Dockerfile --tag unav-recordingmonitor-packer .
cd ../..
Now you can use this image to create the bundle. It is easier than it sounds. Just run the command (from the root folder of the repository):
docker run -u `id -u` --rm -v `pwd`:/pack unav-recordingmonitor-packer
This will run temporary container (--rm
option). This container will run the
bundling-commands inside. As a result, you will get a new shiny package
./dist/unav-recordingmonitor-bundle-X.Y.Z.tgz
PS: we use docker image because it has the appropriate environment, the most
important thing - old glibc, installed on the unav
server.
Several observations about bundle version:
- during build process the
appscheduler
lib will be patched (see section below) - bundle is a result of running
PyInstaller
(see section below)
Without this fix bundled version of the app will not work.
Fix APschedule __init__.py
(inside site-package), use this content:
# These will be removed in APScheduler 4.0.
release = '3.3.1cf' # __import__('pkg_resources').get_distribution('APScheduler').version.split('-')[0]
version_info = '3.3.1cf' # tuple(int(x) if x.isdigit() else x for x in release.split('.'))
version = __version__ = '.'.join(str(x) for x in version_info[:3])
Original solution: agronholm/apscheduler#158 (comment)
pyinstaller -y --log-level=WARN pyinstaller/recordingmonitor.spec
OBSOLETE: nobody will use docker for running this app :(
You need to have targzipped package in the /dist
folder (see Publish new
version section of this guide)
!! don't forget trailing dot !!
docker build -f docker/recordingmonitor/Dockerfile -t unav/recordingmonitor .
curl -X GET http://127.0.0.1:5000/api/v0/about/ping
Almost the same as about/ping
but returns PID of the main process.
curl -X GET http://127.0.0.1:5000/api/v0/about/pid
curl -X GET http://127.0.0.1:5000/api/v0/channels
curl -X POST http://127.0.0.1:5000/api/v0/channels \
-H 'Content-Type: application/json' \
-d '{
"name": "TVE1",
"ip_string": "239.255.20.1:1234"
}'
curl -X GET http://127.0.0.1:5000/api/v0/jobs
curl -X POST http://127.0.0.1:5000/api/v0/jobs \
-H 'content-type: application/json' \
-d '{
"name": "rick and mortie",
"date_from": "2017-12-02T17:40:00+0500",
"duration_sec": 15,
"repeat": {
"interval": {
"minutes": 1,
"date_trim": "2017-12-02T17:45:00+0500"
}
},
"template_name": "capture",
"channel_ID": "d327c73c-1577-42d4-843c-ec494425cec4",
"job_params": {
"ftp_host": "127.0.0.1",
"ftp_user": "user",
"ftp_password": "123"
}
}'
- Maksim Koryukov
GPLv2 - part of CCExtractor and RedHen projects