Fix systemd launch of timesheetsdb
- Add default environment file with postgres config
- Add full path to npm (makes ubuntu happy)
- Call handlers appropriately when systemd unit files are modified
- Add very basic test
Change-Id: I5b1dfab78e449492be193bccfe470813f3028195
diff --git a/templates/default.timesheetsdb.j2 b/templates/default.timesheetsdb.j2
new file mode 100644
index 0000000..749062c
--- /dev/null
+++ b/templates/default.timesheetsdb.j2
@@ -0,0 +1,10 @@
+{#
+SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+SPDX-License-Identifier: Apache-2.0
+#}
+# /etc/default/timesheetsdb
+# {{ ansible_managed }}
+DATABASE_NAME = {{ timesheets_pg_db }}
+DATABASE_PORT = {{ timesheets_pg_db_port }}
+DATABASE_USER = {{ timesheets_pg_db_username }}
+DATABASE_PASS = {{ timesheets_pg_db_password }}
diff --git a/templates/timesheetsdb.service.j2 b/templates/timesheetsdb.service.j2
index 3715246..0a35716 100644
--- a/templates/timesheetsdb.service.j2
+++ b/templates/timesheetsdb.service.j2
@@ -2,21 +2,23 @@
SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
SPDX-License-Identifier: Apache-2.0
#}
+# /etc/systemd/system/timesheetsdb
+# {{ ansible_managed }}
[Unit]
Description=Timesheets DB Service
Documentation=https://github.com/opennetworkinglab/timesheetsdb
After=network-online.target
Wants=network-online.target
-
[Service]
Type=simple
User={{ timesheets_username }}
Group={{ timesheets_groupname }}
-WorkingDirectory={{ timesheets_dir }}/db
-ExecStart=npm run start:prod
+EnvironmentFile=/etc/default/timesheetsdb
+WorkingDirectory={{ timesheets_dir }}/db
+ExecStart=/usr/bin/npm run start:prod
Restart=on-failure
RestartSec=30
diff --git a/templates/timesheetsdb_config.json.j2 b/templates/timesheetsdb_config.json.j2
deleted file mode 100644
index 43ebfab..0000000
--- a/templates/timesheetsdb_config.json.j2
+++ /dev/null
@@ -1,5 +0,0 @@
-{#
-SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
-SPDX-License-Identifier: Apache-2.0
-#}
-{}