Hostwiki / wikijs-sitemap

Sitemap for Wiki.js
MIT License
11 stars 2 forks source link

sitemap.xml is not generated because static/sitemap.xml does not exist. #10

Closed JO3QMA closed 6 months ago

JO3QMA commented 7 months ago

Summary

When trying to generate a sitemap using the Docker version ``wikijs-sitemap'', an error occurs if the file does not exist.

 [[2023-12-19T15:06:59.006Z] Error generating sitemap (attempt 1/15):  Error: Database connection error: ENOENT: no such file or directory, open 'static/sitemap.xml'
     at generateSitemap (/wiki/sitemap/generate-sitemap.js:47:15)
     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
     at async generateSitemapAndLog (/wiki/sitemap/server.js:40:13)
     at async Server.<anonymous> (/wiki/sitemap/server.js:62:5)

Expected Behavior

sitemap.xml with the following content is generated.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<!-- Wiki.js sitemap generator by https://hostwiki.com -->
<url>
    <loc>https://example.com/ja/hoge/fuga</loc>
    <lastmod>2021-09-21T01:20:32.146Z</lastmod>
  </url>
<url>
    <loc>https://example.com/ja/foo</loc>
    <lastmod>2022-02-18T13:39:07.843Z</lastmod>
  </url>
<url>
    <loc>https://example.com/ja/bar/fizz</loc>
    <lastmod>2021-11-03T02:48:14.114Z</lastmod>
  </url>
<url>
    <loc>https://example.com/ja/buzz</loc>
    <lastmod>2023-07-01T12:43:09.629Z</lastmod>
  </url>
<url>

Actual Behavior

sitemap.xml not generated.

Error reading sitemap.xml file

with the error below

Server listening on port 3012
[[2023-12-20T00:09:27.130Z] Error generating sitemap (attempt 1/15):  Error: Database connection error: ENOENT: no such file or directory, open 'static/sitemap.xml'
    at generateSitemap (/wiki/sitemap/generate-sitemap.js:47:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateSitemapAndLog (/wiki/sitemap/server.js:40:13)
    at async Server.<anonymous> (/wiki/sitemap/server.js:62:5)
[[2023-12-20T00:09:27.130Z] Error generating sitemap (attempt 2/15):  Error: Database connection error: ENOENT: no such file or directory, open 'static/sitemap.xml'
    at generateSitemap (/wiki/sitemap/generate-sitemap.js:47:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateSitemapAndLog (/wiki/sitemap/server.js:40:13)
    at async Server.<anonymous> (/wiki/sitemap/server.js:62:5)
[[2023-12-20T00:09:27.130Z] Error generating sitemap (attempt 3/15):  Error: Database connection error: ENOENT: no such file or directory, open 'static/sitemap.xml'
    at generateSitemap (/wiki/sitemap/generate-sitemap.js:47:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateSitemapAndLog (/wiki/sitemap/server.js:40:13)
    at async Server.<anonymous> (/wiki/sitemap/server.js:62:5)
[[2023-12-20T00:09:27.130Z] Error generating sitemap (attempt 4/15):  Error: Database connection error: ENOENT: no such file or directory, open 'static/sitemap.xml'
    at generateSitemap (/wiki/sitemap/generate-sitemap.js:47:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateSitemapAndLog (/wiki/sitemap/server.js:40:13)
    at async Server.<anonymous> (/wiki/sitemap/server.js:62:5)
[Error: ENOENT: no such file or directory, open 'static/sitemap.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'static/sitemap.xml'
}
[[2023-12-20T00:09:27.130Z] Error generating sitemap (attempt 5/15):  Error: Database connection error: ENOENT: no such file or directory, open 'static/sitemap.xml'
    at generateSitemap (/wiki/sitemap/generate-sitemap.js:47:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateSitemapAndLog (/wiki/sitemap/server.js:40:13)
    at async Server.<anonymous> (/wiki/sitemap/server.js:62:5)
[Error: ENOENT: no such file or directory, open 'static/sitemap.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'static/sitemap.xml'
}

Steps to Reproduce

  1. Configure docker-compose.yml according to README
  2. Start Docker

Environment

JO3QMA commented 7 months ago

Work around

Enter the container, write the deleted sitemap.xml of 7b492ff77a5cad7b26c528354bdad72a204c4c72, and restart it to generate it successfully.

$ docker-compose exec wikijs-sitemap /bin/sh
/wiki/sitemap # mkdir static
/wiki/sitemap # touch sitemap.xml
/wiki/sitemap # cat << EOF > ./static/sitemap.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
> <!-- Wiki.js sitemap generator by https://hostwiki.com -->
>
> </urlset>
> EOF
/wiki/sitemap # exit
$ docker-compose restart wikijs-sitemap
[+] Running 1/1
 ? Container wikijs-sitemap  Started                                                                                                                                                                                                                                                                        11.4s
$
Philipinho commented 6 months ago

https://github.com/Hostwiki/wikijs-sitemap/commit/a5ee785698e70e0c7b5463acdf270032deb8d6dd should fix this.

JO3QMA commented 6 months ago

thank you. It's working perfectly.