Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] PopCorn: avoid double runs, use snooze timefile
@ 2024-09-30 19:46 duskmoss
  2024-09-30 20:32 ` duskmoss
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: duskmoss @ 2024-09-30 19:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 771 bytes --]

There is a new pull request by duskmoss against master on the void-packages repository

https://github.com/duskmoss/void-packages popcorn-snooze
https://github.com/void-linux/void-packages/pull/52428

PopCorn: avoid double runs, use snooze timefile
as discussed on #xbps, current will run twice at the snooze time (snooze invocation, then the chpst invocation) and will always run at system start.  

new only runs at system start if haven't run in last day, and doesn't run twice when snooze fires.

#### Testing the changes
- I tested the changes in this PR: **YES** 

#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
x86_64


A patch file from https://github.com/void-linux/void-packages/pull/52428.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-popcorn-snooze-52428.patch --]
[-- Type: text/x-diff, Size: 1403 bytes --]

From daf90785e44915ddd19fe106607b6f0d0e91cd7a Mon Sep 17 00:00:00 2001
From: Moss Hope <duskmoss@proton.me>
Date: Mon, 30 Sep 2024 12:39:59 -0700
Subject: [PATCH] PopCorn: avoid double runs, use snooze timefile

---
 srcpkgs/PopCorn/files/popcorn/run | 8 ++++++--
 srcpkgs/PopCorn/template          | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/PopCorn/files/popcorn/run b/srcpkgs/PopCorn/files/popcorn/run
index 4236e0c4bfa5fe..151ea86a7deb19 100644
--- a/srcpkgs/PopCorn/files/popcorn/run
+++ b/srcpkgs/PopCorn/files/popcorn/run
@@ -6,5 +6,9 @@
 : ${PORT:=8001}
 
 exec 2>&1
-chpst -u _popcorn:_popcorn popcorn --server $SERVER --port $PORT
-exec chpst -u _popcorn:_popcorn snooze popcorn --server $SERVER --port $PORT
+
+[ ! -d /var/cache/popcorn ] && mkdir -p /var/cache/popcorn
+chown _popcorn:_popcorn /var/cache/popcorn
+
+exec chpst -u _popcorn:_popcorn snooze -s 1d -t /var/cache/popcorn/snooze -- sh -c \
+	"popcorn --server $SERVER --port $PORT; : > /var/cache/popcorn/snooze"
diff --git a/srcpkgs/PopCorn/template b/srcpkgs/PopCorn/template
index 8ddf3183fbb668..06b227f9ed223d 100644
--- a/srcpkgs/PopCorn/template
+++ b/srcpkgs/PopCorn/template
@@ -1,7 +1,7 @@
 # Template file for 'PopCorn'
 pkgname=PopCorn
 version=0.4
-revision=11
+revision=12
 build_style=go
 go_import_path=github.com/the-maldridge/popcorn
 go_package="${go_import_path}/cmd/popcorn

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
@ 2024-09-30 20:32 ` duskmoss
  2024-09-30 21:45 ` [PR PATCH] [Updated] " duskmoss
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: duskmoss @ 2024-09-30 20:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

New comment by duskmoss on void-packages repository

https://github.com/void-linux/void-packages/pull/52428#issuecomment-2384093734

Comment:
Maybe I should change this to use touch instead of shell truncation? 

I took the lead from snooze's cron services. However I just noticed this PR, https://github.com/leahneukirchen/snooze/pull/15  (not yet released/updated in voids packages yet).

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
  2024-09-30 20:32 ` duskmoss
@ 2024-09-30 21:45 ` duskmoss
  2024-10-01 12:09 ` abenson
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: duskmoss @ 2024-09-30 21:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

There is an updated pull request by duskmoss against master on the void-packages repository

https://github.com/duskmoss/void-packages popcorn-snooze
https://github.com/void-linux/void-packages/pull/52428

PopCorn: avoid double runs, use snooze timefile
as discussed on #xbps, current will run twice at the snooze time (snooze invocation, then the chpst invocation) and will always run at system start.  

new only runs at system start if haven't run in last day, and doesn't run twice when snooze fires.

#### Testing the changes
- I tested the changes in this PR: **YES** 

#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
x86_64


A patch file from https://github.com/void-linux/void-packages/pull/52428.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-popcorn-snooze-52428.patch --]
[-- Type: text/x-diff, Size: 1405 bytes --]

From 6cfcbdaa3b8824cf7efcbfe75731830e7d134d27 Mon Sep 17 00:00:00 2001
From: Moss Hope <duskmoss@proton.me>
Date: Mon, 30 Sep 2024 12:39:59 -0700
Subject: [PATCH] PopCorn: avoid double runs, use snooze timefile

---
 srcpkgs/PopCorn/files/popcorn/run | 8 ++++++--
 srcpkgs/PopCorn/template          | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/PopCorn/files/popcorn/run b/srcpkgs/PopCorn/files/popcorn/run
index 4236e0c4bfa5fe..34cdbca8f8a458 100644
--- a/srcpkgs/PopCorn/files/popcorn/run
+++ b/srcpkgs/PopCorn/files/popcorn/run
@@ -6,5 +6,9 @@
 : ${PORT:=8001}
 
 exec 2>&1
-chpst -u _popcorn:_popcorn popcorn --server $SERVER --port $PORT
-exec chpst -u _popcorn:_popcorn snooze popcorn --server $SERVER --port $PORT
+
+[ ! -d /var/cache/popcorn ] && mkdir -p /var/cache/popcorn
+chown _popcorn:_popcorn /var/cache/popcorn
+
+exec chpst -u _popcorn:_popcorn snooze -s 1d -t /var/cache/popcorn/snooze -- sh -c \
+	"popcorn --server $SERVER --port $PORT; touch /var/cache/popcorn/snooze"
diff --git a/srcpkgs/PopCorn/template b/srcpkgs/PopCorn/template
index 8ddf3183fbb668..06b227f9ed223d 100644
--- a/srcpkgs/PopCorn/template
+++ b/srcpkgs/PopCorn/template
@@ -1,7 +1,7 @@
 # Template file for 'PopCorn'
 pkgname=PopCorn
 version=0.4
-revision=11
+revision=12
 build_style=go
 go_import_path=github.com/the-maldridge/popcorn
 go_package="${go_import_path}/cmd/popcorn

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
  2024-09-30 20:32 ` duskmoss
  2024-09-30 21:45 ` [PR PATCH] [Updated] " duskmoss
@ 2024-10-01 12:09 ` abenson
  2024-10-01 17:26 ` duskmoss
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: abenson @ 2024-10-01 12:09 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 211 bytes --]

New comment by abenson on void-packages repository

https://github.com/void-linux/void-packages/pull/52428#issuecomment-2385607360

Comment:
That touch will never execute, since nothing after the exec gets run.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
                   ` (2 preceding siblings ...)
  2024-10-01 12:09 ` abenson
@ 2024-10-01 17:26 ` duskmoss
  2024-10-01 17:45 ` duskmoss
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: duskmoss @ 2024-10-01 17:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]

New comment by duskmoss on void-packages repository

https://github.com/void-linux/void-packages/pull/52428#issuecomment-2386568491

Comment:
I can confirm that the touch executes, why do you believe nothing after the exec runs? 


If i add `echo 'snooze'` before the exec, and `; echo 'popcorn!'` after the touch then we get in logs

```
2024-10-01T17:21:11.70711 daemon.notice: Oct  1 10:21:11 popcorn: snooze
2024-10-01T17:21:13.49232 daemon.notice: Oct  1 10:21:13 popcorn: popcorn!
2024-10-01T17:21:13.49368 daemon.notice: Oct  1 10:21:13 popcorn: snooze
```

for the first run, and a snooze file exists in /var/cache/popcorn.

```
ll /var/cache/popcorn
total 512
-rw-r--r-- 1 _popcorn _popcorn 0 Oct  1 10:21 snooze
```


this is the behavior I expect, we call snooze, theres no time file so it executes immediately, touch then creates the time file, service exists, run it starts it again and we call snooze, but this time there is a time file so it waits to execute. 

If I delete  /var/cache/popcorn or /var/cache/popcorn/snooze and try again, we get the same logs and the file reappears. 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
                   ` (3 preceding siblings ...)
  2024-10-01 17:26 ` duskmoss
@ 2024-10-01 17:45 ` duskmoss
  2024-10-01 18:57 ` abenson
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: duskmoss @ 2024-10-01 17:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]

New comment by duskmoss on void-packages repository

https://github.com/void-linux/void-packages/pull/52428#issuecomment-2386568491

Comment:
I can confirm that the touch executes, why do you believe nothing after the exec runs? 


If i add `echo 'snooze'` before the exec, and `; echo 'popcorn!'` after the touch then we get in logs

```
2024-10-01T17:21:11.70711 daemon.notice: Oct  1 10:21:11 popcorn: snooze
2024-10-01T17:21:13.49232 daemon.notice: Oct  1 10:21:13 popcorn: popcorn!
2024-10-01T17:21:13.49368 daemon.notice: Oct  1 10:21:13 popcorn: snooze
```

for the first run, and a snooze file exists in /var/cache/popcorn.

```
ll /var/cache/popcorn
total 512
-rw-r--r-- 1 _popcorn _popcorn 0 Oct  1 10:21 snooze
```


this is the behavior I expect, we call snooze, there is no time file so it executes immediately, touch then creates the time file, service exits, runit starts it again, we call snooze,  this time there is a time file so it waits to execute, after it runs popcorn again it will update the time file

If I delete  /var/cache/popcorn or /var/cache/popcorn/snooze and try again, we get the same logs and the file reappears. 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
                   ` (4 preceding siblings ...)
  2024-10-01 17:45 ` duskmoss
@ 2024-10-01 18:57 ` abenson
  2024-10-01 18:59 ` abenson
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: abenson @ 2024-10-01 18:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

New comment by abenson on void-packages repository

https://github.com/void-linux/void-packages/pull/52428#issuecomment-2386739708

Comment:
> why do you believe nothing after the exec runs

Because `exec` should replace the shell running with `chpst` (and in turn `snooze`). The rest of the script won't be processed. 

I have no idea why yours is not doing that. Maybe my understanding of `exec` is flawed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
                   ` (5 preceding siblings ...)
  2024-10-01 18:57 ` abenson
@ 2024-10-01 18:59 ` abenson
  2024-10-01 19:22 ` duskmoss
  2024-11-01  3:02 ` [PR PATCH] [Merged]: " classabbyamp
  8 siblings, 0 replies; 10+ messages in thread
From: abenson @ 2024-10-01 18:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 245 bytes --]

New comment by abenson on void-packages repository

https://github.com/void-linux/void-packages/pull/52428#issuecomment-2386741725

Comment:
Oh, I see why. You're `exec`'ing a shell and having it run multiple commands. That's an option I guess.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
                   ` (6 preceding siblings ...)
  2024-10-01 18:59 ` abenson
@ 2024-10-01 19:22 ` duskmoss
  2024-11-01  3:02 ` [PR PATCH] [Merged]: " classabbyamp
  8 siblings, 0 replies; 10+ messages in thread
From: duskmoss @ 2024-10-01 19:22 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

New comment by duskmoss on void-packages repository

https://github.com/void-linux/void-packages/pull/52428#issuecomment-2386781210

Comment:
As I mentioned, I followed the pattern that snooze uses in it's cron replacement services. Open to changing it if there is another suggestion that changes the mtime of the file when snooze fires.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Merged]: PopCorn: avoid double runs, use snooze timefile
  2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
                   ` (7 preceding siblings ...)
  2024-10-01 19:22 ` duskmoss
@ 2024-11-01  3:02 ` classabbyamp
  8 siblings, 0 replies; 10+ messages in thread
From: classabbyamp @ 2024-11-01  3:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

There's a merged pull request on the void-packages repository

PopCorn: avoid double runs, use snooze timefile
https://github.com/void-linux/void-packages/pull/52428

Description:
as discussed on #xbps, current will run twice at the snooze time (snooze invocation, then the chpst invocation) and will always run at system start.  

new only runs at system start if haven't run in last day, and doesn't run twice when snooze fires.

#### Testing the changes
- I tested the changes in this PR: **YES** 

#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
x86_64


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-11-01  3:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-30 19:46 [PR PATCH] PopCorn: avoid double runs, use snooze timefile duskmoss
2024-09-30 20:32 ` duskmoss
2024-09-30 21:45 ` [PR PATCH] [Updated] " duskmoss
2024-10-01 12:09 ` abenson
2024-10-01 17:26 ` duskmoss
2024-10-01 17:45 ` duskmoss
2024-10-01 18:57 ` abenson
2024-10-01 18:59 ` abenson
2024-10-01 19:22 ` duskmoss
2024-11-01  3:02 ` [PR PATCH] [Merged]: " classabbyamp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).