Commit Graph

10604 Commits

Author SHA1 Message Date
evazion
c6bf3e7934 BURs: don't automatically retry failed BURs.
If a bulk update job fails, don't automatically retry it. Retrying it
will clobber the original error message if it fails again.
2021-09-20 16:33:23 -05:00
evazion
1d8a3bf09f BURs: allow failed BURs to be reapproved.
Fix it so that you can reapprove a failed BUR to run it again. Before
this would fail because it would end up trying to create the aliases
or implications again, which would fail because they already existed.
Now it ignores when an alias or implication already exists. It will
however finish tagging the posts if they haven't been fully moved.
2021-09-20 16:29:38 -05:00
evazion
0fed4b557b Remove Unicorn.
No longer used now that we use Puma in production. If you still used
Unicorn in your install, switch to `bin/rails server` instead. See
config/puma.rb for config settings.
2021-09-20 06:17:57 -05:00
evazion
68769c7c3b Remove Capistrano.
No longer used now that we use Kubernetes to deploy the site instead of
Capistrano.

If you run your own installation of Danbooru, and you used Capistrano to
deploy your site, it is recommended that you switch to either the Docker
Compose file (for personal installs), the Procfile (for non-Dockerized,
development environments), or Kubernetes (for production environments;
see https://github.com/danbooru/danbooru-infrastructure/tree/master/k8s
for Danbooru's production configuration).
2021-09-20 04:57:41 -05:00
evazion
b7b6797b18 tests: skip weibo tests in CI.
Weibo tests keep failing randomly in CI. Give up and skip them to
prevent them from always marking commits as failed.
2021-09-20 02:17:31 -05:00
evazion
98b3c82ac5 tests: fix deadlock during artist ban test.
The artist ban tests deadlocked because of a weird interaction between
threads and database transactions when tagging posts in parallel. Add a
hack to work around it.
2021-09-20 02:09:14 -05:00
evazion
5995571885 clockwork: add heartbeat task.
Add a cron job that touches a file every minute so we can be sure
clockwork (the cronjob daemon) is still running.
2021-09-20 01:32:12 -05:00
evazion
051f2be93f gems: remove whenever gem.
We're now using the `clockwork` gem for cronjobs in production. See
config/initializers/clockwork.rb.
2021-09-20 01:30:52 -05:00
evazion
65c560c2d7 view components: silence with_variant deprecation warnings. 2021-09-20 01:12:14 -05:00
evazion
d854bf6b53 BURs: update posts in parallel.
When processing an alias, rename, implication, mass update, or nuke,
update the posts in parallel. This means that if we alias foo to bar,
for example, then we use four processes at once to retag the posts from
foo to bar.

This doesn't mean that if we have two aliases in a BUR, we process both
aliases in parallel. It simply means that when processing an alias, we
update the posts in parallel for that alias.
2021-09-20 01:12:14 -05:00
evazion
21f0c2acc3 BURs: add processing and failed states.
When a BUR is approved, put it in a `processing` state. After it
successfully finishes processing, put it in the `approved` state. If it
fails processing, put it in the `failed` state.

If approving the BUR fails with a validation error, for example because
the alias already exists or an implication lacks a wiki, then leave the
BUR in the `pending` state. The `failed` state is only for unexpected
errors during processing.
2021-09-20 01:12:14 -05:00
evazion
9ba84efc07 BURs: process BURs sequentially in a single job.
Change the way BURs are processed. Before, we spawned a background job
for each line of the BUR, then processed each job sequentially. Now, we
process the entire BUR sequentially in a single background job.

This means that:

* BURs are truly sequential now. Before certain things like removing
  aliases weren't actually performed in a background job, so they were
  performed out-of-order before everything else in the BUR.

* Before, if an alias or implication line failed, then subsequent alias
  or implication lines would still be processed. This was because each
  alias or implication line was queued as a separate job, so a failure
  of one job didn't block another. Now, if any alias or implication
  fails, the entire BUR will fail and stop processing after that line.
  This may be good or bad, depending on whether we actually need the BUR
  to be processed in order or not.

* Before, BURs were processed inside a database transaction (except for the
  actual updating of posts). Now they're not. This is because we can't
  afford to hold transactions open while processing long-running aliases
  or implications. This means that if BUR fails in the middle when it is
  initially approved, it will be left in a half-complete state. Before
  it would be rolled back and left in a pending state with no changes
  performed.

* Before, only one BUR at a time could be processed. If multiple BURs
  were approved at the same time, then they would queue up and be
  processed one at a time. Now, multiple BURs can be processed at the
  same time. This may be undesirable when processing large BURs, or BURs
  that must be approved in a specific order.

* Before, large tag category changes could time out. This was because
  they weren't actually performed in a background job. Now they are, so
  they shouldn't time out.
2021-09-20 01:12:14 -05:00
evazion
96c5c346ad ci: allow triggering docker build workflow manually.
Add a `workflow_dispatch` so that it's possible it's possible to trigger
the Docker build workflow manually.

https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
2021-09-18 21:34:28 -05:00
evazion
bc73d47643 Remove .github/stale.yml.
Unused.
2021-09-18 06:01:01 -05:00
evazion
020ed7b735 ci: don't tag short commit hash on Docker images.
Tagging both the long and the short commit hash on images creates too
much clutter in the Github UI.
2021-09-18 05:14:36 -05:00
evazion
52cf13dff1 ci: limit workflow permissions.
Make it so pull requests from outside contributors can't edit workflows
under .github/workflows/ without approval. Also limit workflows to the
minimum permissions necessary.
2021-09-18 04:37:00 -05:00
evazion
39fa2fe02d ci: split docker build workflow from test workflow.
Split up the Github workflow. Instead of one workflow with two jobs, one
to build the Docker image and one to test it, split it into two separate
workflows, one to build and one to test. This way if the Docker build
fails it doesn't try to run the tests, and if the tests fail it only
marks the test workflow as failed, not the entire workflow.

This is especially so the workflows page doesn't show everything as
failing just because the tests failed.

https://github.com/danbooru/danbooru/actions
2021-09-18 01:34:07 -05:00
evazion
cfae1d3b35 Merge pull request #4881 from nottalulah/patch-1
Hide posts not visible to anonymous users from Discord slash commands
2021-09-17 19:18:42 -05:00
evazion
1d4e7ba12f Merge pull request #4855 from nottalulah/lock-moderation
Log mod actions for changes to post locks
2021-09-17 19:06:52 -05:00
Lily
22430f2ec1 Update post_embed.rb 2021-09-17 18:39:56 -03:00
evazion
85d70561e5 rake: change docker build task to buildx. 2021-09-16 02:32:02 -05:00
evazion
965dfaffcf docker: fixup build failure in f359d4476
Forgot to install libarchive-zip-perl.
2021-09-16 02:26:05 -05:00
evazion
313257b771 posts: add exif:<value> search metatags.
Examples:

* https://danbooru.donmai.us/posts?tags=exif:File:ColorComponents
* https://danbooru.donmai.us/posts?tags=exif:GIF:GIFVersion
* https://danbooru.donmai.us/posts?tags=exif:PNG:ColorType

* https://danbooru.donmai.us/posts?tags=exif:PNG:ColorType=RGB
* https://danbooru.donmai.us/posts?tags=exif:GIF:GIFVersion=89a
* https://danbooru.donmai.us/posts?tags=exif:File:ColorComponents=3
2021-09-16 02:13:15 -05:00
evazion
c14e3ec902 Remove staging environment.
We never used any of this stuff. The only environments used are
production, development, and test.
2021-09-16 00:44:26 -05:00
evazion
7e3371f758 docker-compose: use images from Github instead of DockerHub.
Use the Danbooru Docker images from the Github Container Registry
instead of the DockerHub registry for the Compose file. Github is now
considered the canonical source for Danbooru's Docker images. DockerHub
is considered a mirror.

* https://github.com/danbooru/danbooru/pkgs/container/danbooru
* https://hub.docker.com/r/evazion/danbooru
2021-09-16 00:35:30 -05:00
evazion
ea6e47125e metadata: add ability to search exif metadata.
Usage:

* https://danbooru.donmai.us/media_metadata?search[has_metadata]=true
* https://danbooru.donmai.us/media_metadata?search[has_metadata]=false
* https://danbooru.donmai.us/media_metadata?search[metadata_has_key]=GIF:GIFVersion
* https://danbooru.donmai.us/media_metadata?search[metadata][GIF:GIFVersion]=89a
* https://danbooru.donmai.us/media_metadata?search[metadata][GIF:GIFVersion]&search[metadata][GIF:BackgroundColor]=0
2021-09-16 00:25:21 -05:00
evazion
9cc8d8aa4a metadata: add CLI script for printing image metadata
Add a utility script for printing image metadata from the command line.

Usage: `bin/lsmetadata 1.jpg 2.jpg`
2021-09-15 21:39:56 -05:00
evazion
822f72387e metadata: record metadata for corrupt files.
Bug: if ExifTool exited with status 1 because it thought the file was
corrupt, then we didn't record any of the metadata, even though it was
able to read most of it. It turns out there are thousands of posts with
minorly corrupt metadata that ExifTool is still able to read, but will
complain about.

Fix: ignore the exit code of ExifTool and always save whatever metadata
ExifTool is able to return. It will return an `ExifTool:Error` tag in
the event of errors.

Note that there are some (many?) files that are considered corrupt by
ExifTool but not by Vips, and vice versa. Probably because ExifTool only
parses the metadata while Vips only parses the image data.
2021-09-15 20:26:35 -05:00
evazion
f359d44763 metadata: fix failure to get exif data for compressed SWF files.
Fix Exiftool not being able to get the metadata for compressed SWF
files. Exiftool requires Compress::Zlib as an optional dependency to
decompress compressed SWF files, but it wasn't in the Docker image.

Archive::Zip is required for Zip files and Digest::MD5 for certain other
metadata (see "DEPENDENCIES" in exiftool README).
2021-09-15 18:39:42 -05:00
evazion
e16aa7b1c5 Add script to backfill MediaMetadata. 2021-09-15 11:05:45 -05:00
evazion
3b55ca81db Update Procfile.
Usage: `gem install foreman` then `foreman start`.
2021-09-15 06:23:20 -05:00
evazion
16dc017d28 git: add .mailmap file.
Consolidate emails in `git shortlog -e -s -n`.
2021-09-14 21:40:39 -05:00
evazion
ff9a520e29 docker: update Ruby to 2.7.4, FFmpeg to 4.4. 2021-09-14 05:39:18 -05:00
evazion
9552b41c0a Update Ruby gems and Yarn packages. 2021-09-14 05:39:18 -05:00
evazion
34de3b4d18 Merge pull request #4879 from nonamethanks/fix-artist-name
Sources: fix artist_name not being caught in skeb and weibo
2021-09-14 05:39:06 -05:00
nonamethanks
a845477cba Sources: fix artist_name not being caught in skeb and weibo 2021-09-14 11:32:24 +02:00
evazion
f5666fb6f1 Merge pull request #4875 from nonamethanks/lofter-timeout
Lofter: raise timeout for file download
2021-09-14 04:09:12 -05:00
evazion
38e814ddff assets: fix permissions for static images.
Remove execute permission for static images in public/images/.
2021-09-12 10:17:38 -05:00
evazion
4cc8dd41ec puma: add rack-timeout gem.
Unlike Unicorn, Puma doesn't have a builtin HTTP request timeout
mechanism, so we have to use Rack::Timeout instead.

See the caveats in the Rack::Timeout documentation [1]. In Unicorn, a
timeout would send a SIGKILL to the worker, immediately killing it. This
would result in a dropped connection and a Cloudflare 502 error to the
user. In Puma, it raises an exception, which we can catch and return a
better error to the user. On the other hand, raising an exception can
potentially corrupt application state if it's sent at the wrong time, or
be delayed indefinitely if the app is stuck in IO or C extension code.

The default request timeout is 65 seconds. 65 seconds is to give things
like HTTP requests on a 60 second timeout enough time to complete. Set
the RACK_REQUEST_TIMEOUT environment variable to change the timeout.

1: https://github.com/sharpstone/rack-timeout#further-documentation
2021-09-12 09:32:12 -05:00
evazion
23b2a37050 puma: add puma worker killer gem. 2021-09-12 05:51:09 -05:00
evazion
1bb7c50858 posts: unredact file_ext field on hidden posts. 2021-09-12 04:27:49 -05:00
evazion
9bee9223ac docker: add openresty to base image.
Include OpenResty in the base Docker image. This is so we can run
OpenResty in front of Danbooru as a reverse proxy to serve static assets
(CSS, JS, and static images living in public/images).

Including the proxy in the same container as the static assets avoids a
lot of problems with trying to share files across separate containers.
2021-09-12 04:10:33 -05:00
evazion
1fa7114685 docker: add busybox
Add busybox to the base image to add some useful debugging utils inside
the container (e.g. ps, ping, nslookup, traceroute, ip).
2021-09-12 01:08:45 -05:00
evazion
8dbeec4788 tests: fix unit tests. 2021-09-11 20:37:18 -05:00
evazion
eab4e165b1 posts: update safe mode help link.
Change this message:

    2 post(s) on this page were hidden by safe mode. Go to Danbooru or
    disable safe mode to view them (learn more).

To link to [[help:safe mode]] instead of [[help:user settings]].
2021-09-11 19:48:15 -05:00
evazion
0aab81440f puma: add Prometheus metrics exporter.
To test it, run `bin/rails server` then do `curl http://localhost:9393`.

https://github.com/harmjanblok/puma-metrics
2021-09-11 10:09:58 -05:00
evazion
ee1c3c9418 puma: update config.
Update the config for the Puma webserver (used by `bin/rails server`).

* Update default settings.
* Prefix all Puma environment variables with `PUMA_`.
* Enable the Puma control app (`bin/pumactl`).
2021-09-11 10:01:25 -05:00
nonamethanks
9a6a6e52ea Lofter: raise timeout for file download 2021-09-10 13:10:29 +02:00
evazion
8772bc78ec Merge pull request #4865 from nonamethanks/fix-upload-form-submitting-early 2021-09-08 20:31:07 -05:00
nonamethanks
7b817b0a30 Uploads: prevent submission of unfinished uploads 2021-09-08 20:26:53 -05:00