怎样在Ubuntu上部署Internet.ee拍卖系统

2022年12月21日 | 分类: 【技术】

参考:https://github.com/internetee/auction_center

获取源码:

cd /root && git clone https://github.com/internetee/auction_center.git

执行安装程序:

cd /root/auction_center && bin/setup

报错:

rbenv: version `3.0.2' is not installed (set by /root/auction_center/.ruby-version)

既然已经安装 rbenv 3.0.5 ,直接在 .ruby-version 中修改版本号即可。

修改后保存。重新执行安装程序。安装启动,但有报错:

报错:

== Installing dependencies ==
https://github.com/internetee/directo.git (at master@711ce2d) is not yet checked
out. Run `bundle install` first.
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.

按照错误提示:

bundle install

输出:

installing your bundle as root will break this application for all non-root
users on this machine.
...
Bundle complete! 47 Gemfile dependencies, 145 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
1 installed gem you directly depend on is looking for funding.
  Run `bundle fund` for details

报错:

Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install

那就安装 yarn :

sudo apt install yarn

再次执行安装程序,错误被解决,新的报错:

00h00m00s 0/0: : ERROR: There are no scenarios; must have at least one.

参考:https://blog.csdn.net/think_A_lot/article/details/103276336

sudo apt remove cmdtest
sudo apt remove yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn

再次执行安装程序,错误被解决,新的报错:

error normalize-url@8.0.0: The engine "node" is incompatible with this module. Expected version ">=14.16". Got "12.22.9"
error Found incompatible module.

NodeJS版本要求高于 14.16 。

那就升级:
参考:https://amon.org/nodejs-upgrade

再次执行安装程序,错误被解决,新的报错:

warning " > optimize-css-assets-webpack-plugin@6.0.1" has incorrect peer dependency "webpack@^4.0.0".

参考:https://blog.csdn.net/weixin_30363263/article/details/81449032
参考:https://blog.csdn.net/lambertwe/article/details/102532121

npm install -g yarn

再次执行安装程序,错误被解决,还剩一个报错:

== Preparing database ==
/root/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/compile_cache/iseq.rb:13:in `to_binary': wrong argument type false (expected Symbol) (TypeError)
...
        from bin/rails:4:in `<main>'

== Command ["bin/rails db:prepare"] failed ==

参考:https://thinkami.hatenablog.com/entry/2021/11/30/214902

bundle update bootsnap

再次执行安装程序,错误被解决,出现新的报错:

== Preparing database ==
rails aborted!
ActiveRecord::ConnectionNotEstablished: connection to server at "localhost" (127.0.0.1), port 5432 failed: fe_sendauth: no password supplied

Caused by:
PG::ConnectionBad: connection to server at "localhost" (127.0.0.1), port 5432 failed: fe_sendauth: no password supplied

Tasks: TOP => db:prepare
(See full trace by running task with --trace)

== Command ["bin/rails db:prepare"] failed ==

参考:https://amon.org/ubuntu-pgsql

编辑数据库连接文件:config/database.yml

创建应用程序数据库,报错:

connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user "pguser"

数据库其实已经建立。

暂时忽略报错,再次执行安装程序,开始执行数据库导入操作,出现新的报错:

== 20181029121254 AddSettingsRelatedToCurrencyAndPrice: migrating =============
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `value_format' for #<Setting id: nil, code: "auction_currency", description: "Currency in which all invoices and offers are to b...", value: "EUR", created_at: nil, updated_at: nil>
Did you mean?  values_at
/root/auction_center/db/migrate/20181029121254_add_settings_related_to_currency_and_price.rb:11:in `up'

Caused by:
NoMethodError: undefined method `value_format' for #<Setting id: nil, code: "auction_currency", description: "Currency in which all invoices and offers are to b...", value: "EUR", created_at: nil, updated_at: nil>
Did you mean?  values_at
/root/auction_center/db/migrate/20181029121254_add_settings_related_to_currency_and_price.rb:11:in `up'
Tasks: TOP => db:prepare
(See full trace by running task with --trace)

== Command ["bin/rails db:prepare"] failed ==

报错信息显示,导入过程中止,此步骤及后续步骤都不能执行。

关键信息:NoMethodError: undefined method `value_format’

Software for managing TLD domain auctions

Setup
Run bin/setup
Configure database in config/database.yml according to your needs
Adjust configuration variables in config/customization.yml.
Run bundle exec rake db:setup
Default user account
By default, the application creates an administrator user account that should be used only to create new user accounts, and then deleted.

email: administrator@auction.test
password: password
API
System provides auction API endpoint & self-health check API endpoint.

Auction API
Auction center exposes list of current auctions as JSON api. Time reported in ends_at and starts_at are always in UTC.

Request:
GET /auctions HTTP/1.1
Accept: appliction/json

Response:
HTTP/1.1 200
Content-Type: application/json

[
{
“id”: “1b3ee442-e8fe-4922-9492-8fcb9dccc69c”,
“domain_name”: “auction.test”,
“starts_at”: “2019-02-23T22:00:00.000Z”
“ends_at”: “2019-02-24T22:00:00.000Z”
}
]
Health check API
Documentation on health check API is available at project WiKi here.

Settings
There are certain settings stored in the database that are used for the application logic. For example, the currency in which all auctions are conducted. An administrator can change these settings in /admin/settings page.

Jobs
To send out emails and perform other asynchronous tasks, we use a background processing with PostgreSQL as queue backend. To start an executor, use bundle exec rails jobs:work.

Part of running the application according to EIS business rules includes creating new auctions at the beginning of the day. Jobs are scheduled outside of the application, as the exact times are no concern of the application.

Audits
Due to various regulatory requirements, all database tables are audited according to the following procedure:

Changes in public.users table are recorded into audit.users. Audit records action old_value, new_value, recorded_at time according to postgres time zone and object_id which corresponds to the primary key of data in users.
History of each object is visible in the UI for the administrator.
Audit data is never deleted, even if the original object is. For example, if you destroy user with id 123, it’s history can still be accessed under /admin/users/123/versions.
Adding new database table to audits
Create a migration similar to AuditUsersTable
Create a new audit model like Audit::User. Make sure to set self.table_name to audit.your_table
Add auditable concern to administrator routes:
namespace :admin, constraints: Constraints::Administrator.new do
resources posts, concerns: [:auditable]
end
About
Estonian Internet Foundation’s software for auctioning domain names