Sample systemd config
Make num cameras configurable
Change-Id: I4e1bbaf548dc366e7d9e8e3b8a0c369be9eef1e2
diff --git a/README.md b/README.md
index d04d625..1f27021 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,6 @@
The person-detection app runs as a docker container.
```
-docker pull registry.aetherproject.org/aether-apps/person-detection-app:latest
-docker run -itu root:root --privileged --network host registry.aetherproject.org/aether-apps/person-detection-app:latest
+docker pull registry.aetherproject.org/aether-apps/person-detection-app:master
+docker run -itu root:root --rm --name %n --privileged --network host registry.aetherproject.org/aether-apps/person-detection-app:master --url "http://roc.demo.aetherproject.net/aether-roc-api/aether/v2.0.0/connectivity-service-v2/" --keycloak "http://keycloak.demo.aetherproject.net/auth/realms/aether/protocol/openid-connect/token" --enterprise "ase-4g-enterprise" --site "ase-site-4g" --devicegroup "ase-4g-device-group2" --user "onfadmin" --password "changeme" --num 1
```
diff --git a/person_detection/app.py b/person_detection/app.py
index 0c15bec..59cc966 100644
--- a/person_detection/app.py
+++ b/person_detection/app.py
@@ -19,8 +19,10 @@
@app.route('/')
def index():
"""Video streaming home page."""
+ global args
+ devices = {str(x):"Camera "+str(x) for x in range(args.num)}
log.info("{} - connected".format(flask.request.remote_addr))
- return flask.render_template('index.html', devices=config.cameras)
+ return flask.render_template('index.html', devices=devices)
def gen(camera):
@@ -88,6 +90,10 @@
args.add_argument("--password",
help = "ROC password",
type = str)
+ args.add_argument("--num",
+ help="Number of camera devices",
+ default=1,
+ type=int)
args.add_argument("--mbrlow",
help="Low range of MBR",
default=7000000,
diff --git a/resources/person-detection-app.service b/resources/person-detection-app.service
new file mode 100644
index 0000000..3de3072
--- /dev/null
+++ b/resources/person-detection-app.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Person Detection App Container
+After=docker.service
+Requires=docker.service
+
+[Service]
+StandardOutput=file:/var/log/person-detection.log
+StandardError=file:/var/log/person-detection.log
+TimeoutStartSec=0
+ExecStartPre=-/usr/bin/docker stop %n
+ExecStartPre=-/usr/bin/docker rm %n
+ExecStart=/usr/bin/docker run -u root:root --rm --name %n --privileged --network host registry.aetherproject.org/aether-apps/person-detection-app:master --url "http://roc.demo.aetherproject.net/aether-roc-api/aether/v2.0.0/connectivity-service-v2/" --keycloak "http://keycloak.demo.aetherproject.net/auth/realms/aether/protocol/openid-connect/token" --enterprise "ase-4g-enterprise" --site "ase-site-4g" --devicegroup "ase-4g-device-group2" --user "onfadmin" --password "changeme" --num 1
+ExecStop=/usr/bin/docker stop %n
+
+[Install]
+WantedBy=multi-user.target