sion@fish:~ $ curl -fsSL "https://deb.nodesource.com/setup_${NODE_MAJOR}.x" | sudo -E bash - #------------------------------不华丽的分割线-------------------- 2024-05-02 13:22:38 - Installing pre-requisites Hit:1 https://mirrors.aliyun.com/docker-ce/linux/debian bookworm InRelease Hit:2 http://deb.debian.org/debian bookworm InRelease Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease Hit:4 http://deb.debian.org/debian bookworm-updates InRelease Hit:5 http://archive.raspberrypi.com/debian bookworm InRelease Hit:6 https://pkg.cloudflare.com/cloudflared bookworm InRelease Reading package lists... Done Reading package lists... Done Building dependency tree... Done Reading state information... Done apt-transport-https is already the newest version (2.6.1). ca-certificates is already the newest version (20230311).
curl is already the newest version (7.88.1-10+deb12u5). gnupg is already the newest version (2.2.40-1.1). gnupg set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
sion@fish:~ $ sudo apt-get install nodejs -y ---------------------------------------- Reading package lists... Done Building dependency tree... Done Reading state information... Done The following NEW packages will be installed: nodejs 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 30.7 MB of archives. After this operation, 194 MB of additional disk space will be used. Get:1 https://deb.nodesource.com/node_20.x nodistro/main arm64 nodejs arm64 20.12.2-1nodesource1 [30.7 MB] Fetched 30.7 MB in 33s (938 kB/s)
Selecting previously unselected package nodejs. (Reading database ... 79321 files and directories currently installed.) Preparing to unpack .../nodejs_20.12.2-1nodesource1_arm64.deb ... Unpacking nodejs (20.12.2-1nodesource1) ... Setting up nodejs (20.12.2-1nodesource1) ... Processing triggers for man-db (2.11.2-2) ...
sion@fish:~ $ sudo apt update && sudo apt -y install postgresql-16 #------------------------------不华丽的分割线-------------------- Hit:1 https://mirrors.aliyun.com/docker-ce/linux/debian bookworm InRelease Hit:2 http://deb.debian.org/debian bookworm InRelease Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease Hit:4 http://archive.raspberrypi.com/debian bookworm InRelease Hit:5 http://deb.debian.org/debian bookworm-updates InRelease Hit:6 https://pkg.cloudflare.com/cloudflared bookworm InRelease Hit:7 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg InRelease Hit:8 https://deb.nodesource.com/node_20.x nodistro InRelease Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree... Done Reading state information... Done
The following additional packages will be installed: libcommon-sense-perl libjson-perl libjson-xs-perl libllvm16 libpq5 libsensors-config libsensors5 libtypes-serialiser-perl libxslt1.1 libz3-4 postgresql-client-16 postgresql-client-common postgresql-common ssl-cert sysstat Suggested packages: lm-sensors postgresql-doc-16 isag The following NEW packages will be installed: libcommon-sense-perl libjson-perl libjson-xs-perl libllvm16 libpq5 libsensors-config libsensors5 libtypes-serialiser-perl libxslt1.1 libz3-4 postgresql-16 postgresql-client-16 postgresql-client-common postgresql-common ssl-cert sysstat 0 upgraded, 16 newly installed, 0 to remove and 0 not upgraded. Need to get 47.5 MB of archives. After this operation, 216 MB of additional disk space will be used.
Creating config file /etc/default/sysstat with new version update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode Created symlink /etc/systemd/system/sysstat.service.wants/sysstat-collect.timer → /lib/systemd/system/sysstat-collect.timer. Created symlink /etc/systemd/system/sysstat.service.wants/sysstat-summary.timer → /lib/systemd/system/sysstat-summary.timer. Created symlink /etc/systemd/system/multi-user.target.wants/sysstat.service → /lib/systemd/system/sysstat.service. Setting up libjson-xs-perl (4.030-2+b1) ... Setting up postgresql-client-16 (16.2-1.pgdg120+2) ... update-alternatives: using /usr/share/postgresql/16/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode Setting up postgresql-common (259.pgdg120+1) ...
Creating config file /etc/postgresql-common/createcluster.conf with new version Building PostgreSQL dictionaries from installed myspell/hunspell packages... Removing obsolete dictionary files: Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /lib/systemd/system/postgresql.service. Setting up postgresql-16 (16.2-1.pgdg120+2) ... Creating new PostgreSQL cluster 16/main ... /usr/lib/postgresql/16/bin/initdb -D /var/lib/postgresql/16/main --auth-local peer --auth-host scram-sha-256 --no-instructions The files belonging to this database system will be owned by user "postgres". This user must also own the server process.
The database cluster will be initialized with locale "en_GB.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/16/main ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... Asia/Shanghai creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok Processing triggers for man-db (2.11.2-2) ... Processing triggers for libc-bin (2.36-9+rpt2+deb12u6) ...
sion@fish:~ $ sudo systemctl enable --now postgresql #------------------------------不华丽的分割线-------------------- Synchronizing state of postgresql.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable postgresql
sion@fish:~ $ sudo apt-get install redis #------------------------------不华丽的分割线-------------------- Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: redis-server redis-tools Suggested packages: ruby-redis The following NEW packages will be installed: redis redis-server redis-tools 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. Need to get 1,383 kB of archives. After this operation, 9,310 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 https://packages.redis.io/deb bookworm/main arm64 redis-tools arm64 6:7.2.4-1rl1~bookworm1 [1,297 kB] Get:2 https://packages.redis.io/deb bookworm/main arm64 redis-server arm64 6:7.2.4-1rl1~bookworm1 [66.9 kB] Get:3 https://packages.redis.io/deb bookworm/main arm64 redis all 6:7.2.4-1rl1~bookworm1 [19.7 kB] Fetched 1,383 kB in 45s (30.7 kB/s) Selecting previously unselected package redis-tools. (Reading database ... 87805 files and directories currently installed.) Preparing to unpack .../redis-tools_6%3a7.2.4-1rl1~bookworm1_arm64.deb ... Unpacking redis-tools (6:7.2.4-1rl1~bookworm1) ... Selecting previously unselected package redis-server. Preparing to unpack .../redis-server_6%3a7.2.4-1rl1~bookworm1_arm64.deb ... Unpacking redis-server (6:7.2.4-1rl1~bookworm1) ... Selecting previously unselected package redis. Preparing to unpack .../redis_6%3a7.2.4-1rl1~bookworm1_all.deb ... Unpacking redis (6:7.2.4-1rl1~bookworm1) ... Setting up redis-tools (6:7.2.4-1rl1~bookworm1) ... Setting up redis-server (6:7.2.4-1rl1~bookworm1) ... Setting up redis (6:7.2.4-1rl1~bookworm1) ... Processing triggers for man-db (2.11.2-2) ...
开启redis服务器
1 2 3 4 5 6
sion@fish:~ $ sudo systemctl enable --now redis-server #------------------------------不华丽的分割线-------------------- Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable redis-server Created symlink /etc/systemd/system/redis.service → /lib/systemd/system/redis-server.service. Created symlink /etc/systemd/system/multi-user.target.wants/redis-server.service → /lib/systemd/system/redis-server.service.
---------------------- ... query: UPDATE "user" SET "alsoKnownAs" = NULL WHERE "alsoKnownAs" = '{}' query: COMMENT ON COLUMN "user"."alsoKnownAs" IS 'URIs the user is known as too' query: ALTER TABLE "user" DROP COLUMN "alsoKnownAsOld" query: INSERT INTO "migrations"("timestamp", "name") VALUES ($1, $2) -- PARAMETERS: [1714099399879,"AlterAkaType1714099399879"] Migration AlterAkaType1714099399879 has been executed successfully. query: COMMIT
[Service] Type=simple User=firefish Group=firefish UMask=0027 ExecStart=/usr/bin/pnpmrunstart WorkingDirectory=/home/firefish/firefish Environment="NODE_ENV=production" Environment="npm_config_cache=/tmp" Environment="NODE_OPTIONS=--max-old-space-size=3072" # uncomment the following line if you use jemalloc (note that the path varies on different environments) # Environment="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2" StandardOutput=journal StandardError=journal SyslogIdentifier=firefish TimeoutSec=60 Restart=always
git checkout -- packages/backend/assets && git pull --ff origin main
1
corepack prepare pnpm@latest --activate && pnpm install --frozen-lockfile && NODE_ENV='production' NODE_OPTIONS='--max_old_space_size=3072' pnpm run rebuild && pnpm run migrate
1
sudo systemctl start firefish.service
合成命令
1
sudo su --login firefish && cd ~/firefish && systemctl stop firefish.service && git checkout -- packages/backend/assets && git pull --ff origin main && corepack prepare pnpm@latest --activate && pnpm install --frozen-lockfile && NODE_ENV='production' NODE_OPTIONS='--max_old_space_size=3072' pnpm run rebuild && pnpm run migrate && systemctl start firefish.service
【2024.7.30】更新时,受网络影响,npm包的下载会中断:
error
1 2 3 4 5 6 7 8 9 10 11
ETIMEDOUT request to https://r.cnpmjs.org/@types/eslint/-/eslint-9.6.0.tgz failed, reason:
FetchError: request to https://r.cnpmjs.org/@types/eslint/-/eslint-9.6.0.tgz failed, reason: at ClientRequest.<anonymous> (/home/firefish/.cache/node/corepack/v1/pnpm/9.6.0/dist/pnpm.cjs:66479:18) at ClientRequest.emit (node:events:519:28) at TLSSocket.socketErrorListener (node:_http_client:500:9) at TLSSocket.emit (node:events:531:35) at emitErrorNT (node:internal/streams/destroy:169:8) at emitErrorCloseNT (node:internal/streams/destroy:128:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) Progress: resolved 1339, reused 1217, downloaded 121, added 121
这时候多试几次即可: pnpm install --frozen-lockfile && NODE_ENV='production' NODE_OPTIONS='--max_old_space_size=3072' pnpm run rebuild && pnpm run migrate
【2024.7.6】更新时,受内存大小限制(比如本站部署在4g的树莓派上,内存就很小,编译时经常中断),有时候更新在 pnpm run rebuild时会中断,这时候需要关闭无用软件,增加可用内存。