Hi folks,
With joy I found that Discourse is packaged and I can easily configure and deploy it and it works great. Thank you mainainers!
The only thing I miss is discourse
CLI command that is by default present in containerized version of Discourse.
I looked into the container how it works I realized that discourse
is just a very simple shell script that executes bundle
. I looked at the NixOS discourse.service
and I executed the same commands like I was in a container using discourse
shell script:
- first I login as discourse
su discourse -s `which bash`
- by trial / error I realized I need some env var (as they’re in the
discourse.service
):
export HOME=/run/discourse/home
export MALLOC_ARENA_MAX=2
export RAILS_ENV=production
export UNICORN_LISTENER=/run/discourse/sockets/unicorn.sock
export UNICORN_SIDEKIQS=1
export UNICORN_TIMEOUT=30
- and then execute
cd /nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse
/nix/store/23m9lin6g1gjj7v7p4jvfgyw2xd7sqsa-discourse-ruby-env-3.2.2/bin/bundle exec script/discourse enable_restore
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Restore are now permitted. Disable them with `disable_restore`
- and that worked, now restore:
/nix/store/23m9lin6g1gjj7v7p4jvfgyw2xd7sqsa-discourse-ruby-env-3.2.2/bin/bundle exec script/discourse restore /tmp/my-forum-2024-06-01-031039-v20240425133407.tar.gz
discourse restore /tmp/my-forum-2024-06-01-031039-v20240425133407.tar.gz
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Starting restore: /tmp/my-forum-2024-06-01-031039-v20240425133407.tar.gz
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/tmp/restores/default/2024-07-05-041305 exists...
Copying archive to tmp directory...
EXCEPTION: /nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/lib/discourse.rb:138:in `exec': Failed to copy archive to tmp directory.
cp: cannot stat '/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/public/backups/default/tmp/my-forum-2024-06-01-031039-v20240425133407.tar.gz': No such file or directory
/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/lib/discourse.rb:172:in `execute_command'
/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/lib/discourse.rb:138:in `exec'
/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/lib/discourse.rb:34:in `execute_command'
/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/lib/backup_restore/local_backup_store.rb:46:in `download_file'
/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/lib/backup_restore/backup_file_handler.rb:62:in `copy_archive_to_tmp_directory'
/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/lib/backup_restore/backup_file_handler.rb:22:in `decompress'
/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/lib/backup_restore/restorer.rb:42:in `run'
script/discourse:149:in `restore'
/nix/store/9wsxc0cirvk6fippc0zc8z8yswlyklk0-ruby3.2-thor-1.3.0/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
/nix/store/9wsxc0cirvk6fippc0zc8z8yswlyklk0-ruby3.2-thor-1.3.0/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/nix/store/9wsxc0cirvk6fippc0zc8z8yswlyklk0-ruby3.2-thor-1.3.0/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
/nix/store/9wsxc0cirvk6fippc0zc8z8yswlyklk0-ruby3.2-thor-1.3.0/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
script/discourse:290:in `<main>'
Trying to rollback...
There was no need to rollback
Cleaning stuff up...
Removing tmp '/nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/tmp/restores/default/2024-07-05-041305' directory...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.
- that failed, by assumption is that it wanted to write into read-only Nix store, but that’s not a problem since:
ls -l /nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/public/backups
lrwxrwxrwx 1 discourse discourse 26 Jul 5 03:57 /nix/store/r8qpj1bjvjqk56c7nsdlf3j695khnfsg-discourse-3.2.2/share/discourse/public/backups -> /var/lib/discourse/backups
And I checked that /var/lib/discourse/backups
writable for discourse
user.
Any ideas?
Thank you.