lockfiles

This commit is contained in:
Peter Kleiweg
2026-03-19 14:42:35 +01:00
parent 025c134c07
commit 6d15441a5a
11 changed files with 221 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -43,6 +44,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/AT5/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
req, err := http.NewRequest("GET", "https://rss.at5.nl/rss", nil)
p(err)
req.Header.Set("User-Agent", agent)
@@ -101,3 +108,16 @@ func main() {
}()
}
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -10,6 +10,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -47,6 +48,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/Amsterdam/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
req, err := http.NewRequest("GET", "https://www.amsterdam.nl/nieuws/nieuwsoverzicht/?rss=true", nil)
p(err)
req.Header.Set("User-Agent", agent)
@@ -71,7 +78,7 @@ func main() {
t, err = time.Parse(time.RFC1123, item.PubDate)
}
p(err)
dirname := fmt.Sprintf("/net/corpora/nlnieuws/amsterdam/%d/%02d", t.Year(), int(t.Month()))
dirname := fmt.Sprintf("/net/corpora/nlnieuws/Amsterdam/%d/%02d", t.Year(), int(t.Month()))
if exists(dirname + "/lock") {
continue
}
@@ -178,3 +185,16 @@ func addEnd(s string) string {
}
return s + ".\n"
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -10,6 +10,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -62,6 +63,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/GG/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
req, err := http.NewRequest("GET", "https://gemeente.groningen.nl/feed/rss/nieuws", nil)
p(err)
req.Header.Set("User-Agent", agent)
@@ -211,3 +218,16 @@ func addEnd(s string) string {
func fixSpace(s string) string {
return strings.Join(strings.Fields(s), " ")
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -59,6 +60,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/NOS/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
resp, err := http.Get("https://feeds.nos.nl/nosnieuwsalgemeen")
p(err)
body, err := io.ReadAll(resp.Body)
@@ -183,3 +190,16 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
p(os.Chtimes(filename+".json", timestamp, timestamp))
return true
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -12,6 +12,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -71,6 +72,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/NU/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
resp, err := http.Get("https://www.nu.nl/rss")
p(err)
body, err := io.ReadAll(resp.Body)
@@ -253,3 +260,16 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
func fixSpace(s string) string {
return strings.Join(strings.Fields(s), " ")
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -11,6 +11,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -62,6 +63,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/NieuwsNL/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
req, err := http.NewRequest("GET", "https://nieuws.nl/sitemap/news.xml", nil)
p(err)
req.Header.Set("User-Agent", agent)
@@ -230,3 +237,16 @@ func addEnd(s string) string {
func fixSpace(s string) string {
return strings.Join(strings.Fields(s), " ")
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -43,6 +44,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/RO/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
req, err := http.NewRequest("GET", "https://reportersonline.nl/feed/", nil)
p(err)
req.Header.Set("User-Agent", agent)
@@ -102,3 +109,16 @@ func main() {
}
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -43,6 +44,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/Sargasso/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
req, err := http.NewRequest("GET", "https://sargasso.nl/feed/", nil)
p(err)
req.Header.Set("User-Agent", agent)
@@ -102,3 +109,16 @@ func main() {
}
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -10,6 +10,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -61,6 +62,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/Sikkom/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
resp, err := http.Get("https://www.sikkom.nl/api/feed/rss")
p(err)
body, err := io.ReadAll(resp.Body)
@@ -242,3 +249,16 @@ func addEnd(s string) string {
func fixSpace(s string) string {
return strings.Join(strings.Fields(s), " ")
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -43,6 +44,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/Tzum/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
req, err := http.NewRequest("GET", "https://www.tzum.info/feed/", nil)
p(err)
req.Header.Set("User-Agent", agent)
@@ -102,3 +109,16 @@ func main() {
}
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}

View File

@@ -11,6 +11,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
@@ -76,6 +77,12 @@ func main() {
}
}()
myLock := "/net/corpora/nlnieuws/VRT/lock"
mkLock(myLock)
defer func() {
_ = os.Remove(myLock)
}()
resp, err := http.Get("https://www.vrt.be/vrtnws/nl.rss.headlines.xml")
p(err)
body, err := io.ReadAll(resp.Body)
@@ -323,3 +330,16 @@ func addEnd(s string) string {
func fixSpace(s string) string {
return strings.Join(strings.Fields(s), " ")
}
func mkLock(filename string) {
pid := os.Getpid()
link := fmt.Sprintf("%s.%d", filepath.Base(filename), pid)
p(os.Symlink(link, filename))
name, err := os.Readlink(filename)
p(err)
if name != link {
p(fmt.Errorf("wrong lock name %q, should be %q", name, link))
}
}