Skip to content

Commit 9f402bd

Browse files
committed
Feature: custom queries #32
This commit enhances previous one to: - not fail if configuration file does not contain custom_queries part - ensure, that .config folder can be created in docker container as well - ensure, that a docker container can be stopped on SIGTERM - ensure, that right default logging setting is given.
1 parent 8938f14 commit 9f402bd

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ RUN echo "NoExtract = !usr/share/doc/timew/*" >> /etc/pacman.conf \
2626
&& pacman -S --noconfirm task timew cronie vi \
2727
&& pacman -S --noconfirm python-pip \
2828
&& useradd -m -d /app task && passwd -d task \
29-
&& chown -R task:task /app && chmod -R 775 /app \
3029
&& mkdir -p /app/bin \
3130
&& mkdir -p /app/taskdata \
3231
&& mkdir -p /app/.task/hooks \
3332
&& mkdir -p /app/.timewarrior/data/ \
33+
&& mkdir -p /app/.config/taskwarrior-web/ \
34+
&& chown -R task:task /app && chmod -R 775 /app \
3435
&& systemctl enable cronie.service \
3536
&& cp /usr/share/doc/timew/ext/on-modify.timewarrior /app/.task/hooks/on-modify.timewarrior \
3637
&& chmod +x /app/.task/hooks/on-modify.timewarrior \
@@ -67,6 +68,7 @@ EXPOSE 3000
6768
# Taskwarrior data volume
6869
VOLUME /app/taskdata/
6970
VOLUME /app/.timewarrior/
71+
VOLUME /app/.config/taskwarrior-web/
7072

7173
ENV TASKRC="/app/.taskrc"
7274
ENV TASKDATA="/app/taskdata"

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ That should do it.
5959

6060
The docker shares following directories as volumes to store data:
6161

62-
| Volume path | Purpose |
63-
| ----------------- | ---------------------------------------------- |
64-
| /app/taskdata | Stores task data (mostly taskchampion.sqlite3) |
65-
| /app/.timewarrior | Stores timewarrior data |
62+
| Volume path | Purpose |
63+
| ----------------- | ---------------------------------------------- |
64+
| /app/taskdata | Stores task data (mostly taskchampion.sqlite3) |
65+
| /app/.timewarrior | Stores timewarrior data |
66+
| /app/.config/taskwarrior-web | Stores taskwarrior-web configuration file |
6667

6768
It is recommend to specify the corresponding volume in order to persist the data.
6869

@@ -114,17 +115,13 @@ That should be it! Now you have the server running at `localhost:3000` accessibl
114115

115116
### Troubleshooting
116117

117-
if you are receiving the following error in step 5
118-
118+
By default the log level is set to `INFO`. If a more detailed log is required, the application can be run with DEBUG or even TRACE messages.
119+
For debug messages, just set the environment "RUST_LOG" to "DEBUG":
119120
```shell
120-
121-
thread 'main' panicked at build.rs:7:19:
122-
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
123-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
124-
121+
env RUST_LOG="DEBUG" cargo run
125122
```
126123

127-
It's because, `tailwindcss-cli` is missing
124+
If a fine granular configuration is desired - the application log itself is captured with the name `taskwarrior_web`.
128125

129126
## Customizing
130127

@@ -260,7 +257,7 @@ As soon as one of the other reports like `next`, `pending` or others are selecte
260257

261258
Beside of a configuration file, it is possible to configure via environment variables as well:
262259
```shell
263-
env TWK_custom_queries__one_query__fixed_key=ni TWK_custom_queries__one_query__query="end.after:today-1wk and status:completed" TWK_custom_queries__one_query__description="completed last 7days" RUST_LOG="INFO" cargo run
260+
env TWK_custom_queries__one_query__fixed_key=ni TWK_custom_queries__one_query__query="end.after:today-1wk and status:completed" TWK_custom_queries__one_query__description="completed last 7days" cargo run
264261
```
265262

266263
The same way it is possible to configure the docker container accordingly.

docker/start.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ if [[ ! -f "$TASKRC" ]]; then
1717
fi
1818

1919
cd $HOME/bin
20-
exec ./taskwarrior-web
20+
exec ./taskwarrior-web &
21+
pid=$!
22+
trap 'kill -SIGTERM $pid; wait $pid' SIGTERM
23+
wait $pidh

src/core/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct CustomQuery {
1515

1616
#[derive(serde::Deserialize, Clone, Debug)]
1717
pub struct AppSettings {
18+
#[serde(default)]
1819
pub custom_queries: HashMap<String, CustomQuery>,
1920
}
2021

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn init_tracing() {
8585
tracing_subscriber::registry()
8686
.with(
8787
tracing_subscriber::EnvFilter::try_from_default_env()
88-
.unwrap_or_else(|_| "org_me=debug,tower_http=debug".into()),
88+
.unwrap_or_else(|_| "taskwarrior_web=info,tower_http=info".into()),
8989
)
9090
.with(tracing_subscriber::fmt::layer().with_line_number(true))
9191
.init();

0 commit comments

Comments
 (0)