2021年04月

2021-04-01 周四

企业微信 OAuth2.0 授权

在企业微信内打开网页,需要登录,一旦缓存清空后登录的状态就没了,部分手机可能需要频繁的登录,因此造成了用户体验上的不便

如果将授权交由企业微信,会方便很多,可以每次打开无感登录,由企业微信服务器判断用户的身份是否合法

这就是 OAuth 2.0,我们作为服务提供者(Resource Owner),只需要把请求传递给授权服务(Authorization Server),然后用户拿着授权服务的授权码给我们就行,我们拿到授权码后再交给授权服务来获得用户消息

企业微信文档:https://open.work.weixin.qq.com/api/doc/90000/90135/91020

使用 EasyWeChat 获取授权十分方便,只需要初始化拿到 oauth 直接指向 user 就行

 $oauth->user();

 

2021-04-12 周一

Sentry 由 21.3.0 升级到 21.3.1

由于 .env 文件在版本控制中,所以得记得每次都编辑一下 .env 文件中的东西

 git add .env

git stash

git pull

git checkout 21.3.1

nano .env // 编辑端口切换至 32707

// 暂停、更新、重启
docker-compose stop

docker-compose build

docker-compose run --rm web upgrade

docker-compose up -d

// 丢弃更改
git stash drop stash@{0}

 

日志:

 root@tabll-server:/home/tabll/Sentry/onpremise# git add .env
root@tabll-server:/home/tabll/Sentry/onpremise# 
root@tabll-server:/home/tabll/Sentry/onpremise# git stash
保存工作目录和索引状态 WIP on (no branch): 315cbaa release: 21.3.1
root@tabll-server:/home/tabll/Sentry/onpremise# git pull
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 25 (delta 12), reused 13 (delta 8), pack-reused 0
展开对象中: 100% (25/25), 13.03 KiB | 404.00 KiB/s, 完成.
来自 https://github.com/getsentry/onpremise
   2223723..662a773  master     -> origin/master
 * [新标签]          21.4.0     -> 21.4.0
您当前不在一个分支上。
请指定您要合并哪一个分支。
详见 git-pull(1)。

    git pull <远程> <分支>

root@tabll-server:/home/tabll/Sentry/onpremise# git checkout 21.4.0
之前的 HEAD 位置是 315cbaa release: 21.3.1
HEAD 目前位于 faf1088 release: 21.4.0
root@tabll-server:/home/tabll/Sentry/onpremise# nano .env
root@tabll-server:/home/tabll/Sentry/onpremise# docker-compose stop
Stopping sentry_onpremise_nginx_1                                    ... done
Stopping sentry_onpremise_sentry-cleanup_1                           ... done
Stopping sentry_onpremise_subscription-consumer-transactions_1       ... done
Stopping sentry_onpremise_ingest-consumer_1                          ... done
Stopping sentry_onpremise_post-process-forwarder_1                   ... done
Stopping sentry_onpremise_cron_1                                     ... done
Stopping sentry_onpremise_subscription-consumer-events_1             ... done
Stopping sentry_onpremise_worker_1                                   ... done
Stopping sentry_onpremise_web_1                                      ... done
Stopping sentry_onpremise_snuba-sessions-consumer_1                  ... done
Stopping sentry_onpremise_snuba-replacer_1                           ... done
Stopping sentry_onpremise_snuba-api_1                                ... done
Stopping sentry_onpremise_snuba-subscription-consumer-transactions_1 ... done
Stopping sentry_onpremise_snuba-subscription-consumer-events_1       ... done
Stopping sentry_onpremise_snuba-transactions-consumer_1              ... done
Stopping sentry_onpremise_snuba-consumer_1                           ... done
Stopping sentry_onpremise_snuba-outcomes-consumer_1                  ... done
Stopping sentry_onpremise_relay_1                                    ... done
Stopping sentry_onpremise_snuba-cleanup_1                            ... done
Stopping sentry_onpremise_symbolicator-cleanup_1                     ... done
Stopping sentry_onpremise_smtp_1                                     ... done
Stopping sentry_onpremise_postgres_1                                 ... done
Stopping sentry_onpremise_memcached_1                                ... done
Stopping sentry_onpremise_symbolicator_1                             ... done
Stopping sentry_onpremise_kafka_1                                    ... done
Stopping sentry_onpremise_redis_1                                    ... done
Stopping sentry_onpremise_zookeeper_1                                ... done
Stopping sentry_onpremise_clickhouse_1                               ... done
root@tabll-server:/home/tabll/Sentry/onpremise# docker-compose build
smtp uses an image, skipping
memcached uses an image, skipping
redis uses an image, skipping
postgres uses an image, skipping
zookeeper uses an image, skipping
kafka uses an image, skipping
clickhouse uses an image, skipping
geoipupdate uses an image, skipping
snuba-api uses an image, skipping
snuba-consumer uses an image, skipping
snuba-outcomes-consumer uses an image, skipping
snuba-sessions-consumer uses an image, skipping
snuba-transactions-consumer uses an image, skipping
snuba-replacer uses an image, skipping
snuba-subscription-consumer-events uses an image, skipping
snuba-subscription-consumer-transactions uses an image, skipping
symbolicator uses an image, skipping
web uses an image, skipping
cron uses an image, skipping
worker uses an image, skipping
ingest-consumer uses an image, skipping
post-process-forwarder uses an image, skipping
subscription-consumer-events uses an image, skipping
subscription-consumer-transactions uses an image, skipping
relay uses an image, skipping
nginx uses an image, skipping
Building snuba-cleanup
Step 1/5 : ARG BASE_IMAGE
Step 2/5 : FROM ${BASE_IMAGE}
 ---> 3bde1fc93fb0
Step 3/5 : RUN apt-get update && apt-get install -y --no-install-recommends cron &&     rm -r /var/lib/apt/lists/*
 ---> Running in e8c8f17fd826
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [272 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [9504 B]
Fetched 8427 kB in 3s (2764 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  lsb-base sensible-utils
Suggested packages:
  anacron logrotate checksecurity
Recommended packages:
  default-mta | mail-transport-agent
The following NEW packages will be installed:
  cron lsb-base sensible-utils
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 143 kB of archives.
After this operation, 383 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 sensible-utils all 0.0.12 [15.8 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 lsb-base all 10.2019051400 [28.4 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 cron amd64 3.0pl1-134+deb10u1 [99.0 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 143 kB in 0s (613 kB/s)
Selecting previously unselected package sensible-utils.
(Reading database ... 6840 files and directories currently installed.)
Preparing to unpack .../sensible-utils_0.0.12_all.deb ...
Unpacking sensible-utils (0.0.12) ...
Selecting previously unselected package lsb-base.
Preparing to unpack .../lsb-base_10.2019051400_all.deb ...
Unpacking lsb-base (10.2019051400) ...
Selecting previously unselected package cron.
Preparing to unpack .../cron_3.0pl1-134+deb10u1_amd64.deb ...
Unpacking cron (3.0pl1-134+deb10u1) ...
Setting up lsb-base (10.2019051400) ...
Setting up sensible-utils (0.0.12) ...
Setting up cron (3.0pl1-134+deb10u1) ...
Adding group `crontab' (GID 101) ...
Done.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Removing intermediate container e8c8f17fd826
 ---> 675a02f9204e
Step 4/5 : COPY entrypoint.sh /entrypoint.sh
 ---> 7020fbd546d3
Step 5/5 : ENTRYPOINT ["/entrypoint.sh"]
 ---> Running in 7cbc87262c41
Removing intermediate container 7cbc87262c41
 ---> fc84a53e10b6

Successfully built fc84a53e10b6
Successfully tagged snuba-cleanup-onpremise-local:latest
Building snuba-transactions-cleanup
Step 1/5 : ARG BASE_IMAGE
Step 2/5 : FROM ${BASE_IMAGE}
 ---> 3bde1fc93fb0
Step 3/5 : RUN apt-get update && apt-get install -y --no-install-recommends cron &&     rm -r /var/lib/apt/lists/*
 ---> Using cache
 ---> 675a02f9204e
Step 4/5 : COPY entrypoint.sh /entrypoint.sh
 ---> Using cache
 ---> 7020fbd546d3
Step 5/5 : ENTRYPOINT ["/entrypoint.sh"]
 ---> Using cache
 ---> fc84a53e10b6

Successfully built fc84a53e10b6
Successfully tagged snuba-cleanup-onpremise-local:latest
Building symbolicator-cleanup
Step 1/5 : ARG BASE_IMAGE
Step 2/5 : FROM ${BASE_IMAGE}
 ---> 77d674e404a3
Step 3/5 : RUN apt-get update && apt-get install -y --no-install-recommends cron &&     rm -r /var/lib/apt/lists/*
 ---> Using cache
 ---> 6d313911c20b
Step 4/5 : COPY entrypoint.sh /entrypoint.sh
 ---> Using cache
 ---> 8a23c6234df8
Step 5/5 : ENTRYPOINT ["/entrypoint.sh"]
 ---> Using cache
 ---> 818a887df7fa

Successfully built 818a887df7fa
Successfully tagged symbolicator-cleanup-onpremise-local:latest
Building sentry-cleanup
Step 1/5 : ARG BASE_IMAGE
Step 2/5 : FROM ${BASE_IMAGE}
 ---> b679e17d6454
Step 3/5 : RUN apt-get update && apt-get install -y --no-install-recommends cron &&     rm -r /var/lib/apt/lists/*
 ---> Running in c2bcff28fd85
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [272 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [9504 B]
Fetched 8427 kB in 3s (2939 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  lsb-base sensible-utils
Suggested packages:
  anacron logrotate checksecurity
Recommended packages:
  default-mta | mail-transport-agent
The following NEW packages will be installed:
  cron lsb-base sensible-utils
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 143 kB of archives.
After this operation, 383 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 sensible-utils all 0.0.12 [15.8 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 lsb-base all 10.2019051400 [28.4 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 cron amd64 3.0pl1-134+deb10u1 [99.0 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 143 kB in 0s (478 kB/s)
Selecting previously unselected package sensible-utils.
(Reading database ... 11935 files and directories currently installed.)
Preparing to unpack .../sensible-utils_0.0.12_all.deb ...
Unpacking sensible-utils (0.0.12) ...
Selecting previously unselected package lsb-base.
Preparing to unpack .../lsb-base_10.2019051400_all.deb ...
Unpacking lsb-base (10.2019051400) ...
Selecting previously unselected package cron.
Preparing to unpack .../cron_3.0pl1-134+deb10u1_amd64.deb ...
Unpacking cron (3.0pl1-134+deb10u1) ...
Setting up lsb-base (10.2019051400) ...
Setting up sensible-utils (0.0.12) ...
Setting up cron (3.0pl1-134+deb10u1) ...
Adding group `crontab' (GID 101) ...
Done.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Removing intermediate container c2bcff28fd85
 ---> 75c175ce56cd
Step 4/5 : COPY entrypoint.sh /entrypoint.sh
 ---> 9efcd15d6eb5
Step 5/5 : ENTRYPOINT ["/entrypoint.sh"]
 ---> Running in 55d04f17312d
Removing intermediate container 55d04f17312d
 ---> 210e6ddb5e1c

Successfully built 210e6ddb5e1c
Successfully tagged sentry-cleanup-onpremise-local:latest
root@tabll-server:/home/tabll/Sentry/onpremise# docker-compose run --rm web upgrade
Starting sentry_onpremise_postgres_1     ... done
Starting sentry_onpremise_symbolicator_1 ... done
Starting sentry_onpremise_smtp_1         ... done
Starting sentry_onpremise_memcached_1    ... done
Starting sentry_onpremise_redis_1        ... done
Starting sentry_onpremise_clickhouse_1   ... done
Starting sentry_onpremise_zookeeper_1    ... done
Starting sentry_onpremise_kafka_1        ... done
Starting sentry_onpremise_snuba-replacer_1                           ... done
Starting sentry_onpremise_snuba-transactions-consumer_1              ... done
Starting sentry_onpremise_snuba-subscription-consumer-transactions_1 ... done
Starting sentry_onpremise_snuba-subscription-consumer-events_1       ... done
Starting sentry_onpremise_snuba-outcomes-consumer_1                  ... done
Starting sentry_onpremise_snuba-sessions-consumer_1                  ... done
Starting sentry_onpremise_snuba-api_1                                ... done
Starting sentry_onpremise_snuba-consumer_1                           ... done
02:52:17 [INFO] sentry.plugins.github: apps-not-configured
* Unknown config option found: 'slack.legacy-app'
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, jira_ac, nodestore, sentry, sessions, sites, social_auth
Running migrations:
User Options: 100% |########################################################################################################################################################################################| Time: 0:00:00
 OK
  Applying sentry.0186_add_externalactor... OK
Creating missing DSNs
Correcting Group.num_comments counter
root@tabll-server:/home/tabll/Sentry/onpremise# docker-compose up -d
sentry_onpremise_memcached_1 is up-to-date
sentry_onpremise_postgres_1 is up-to-date
sentry_onpremise_clickhouse_1 is up-to-date
sentry_onpremise_symbolicator_1 is up-to-date
Starting sentry_onpremise_symbolicator-cleanup_1 ... 
sentry_onpremise_redis_1 is up-to-date
sentry_onpremise_zookeeper_1 is up-to-date
Starting sentry_onpremise_geoipupdate_1          ... 
Starting sentry_onpremise_symbolicator-cleanup_1                       ... done
Starting sentry_onpremise_geoipupdate_1                                ... done
Recreating sentry_onpremise_snuba-subscription-consumer-transactions_1 ... done
Recreating sentry_onpremise_snuba-api_1                                ... done
Recreating sentry_onpremise_snuba-replacer_1                           ... done
Recreating sentry_onpremise_relay_1                                    ... done
Creating sentry_onpremise_snuba-transactions-cleanup_1                 ... done
Recreating sentry_onpremise_snuba-transactions-consumer_1              ... done
Recreating sentry_onpremise_snuba-cleanup_1                            ... done
Recreating sentry_onpremise_snuba-consumer_1                           ... done
Recreating sentry_onpremise_snuba-subscription-consumer-events_1       ... done
Recreating sentry_onpremise_snuba-sessions-consumer_1                  ... done
Recreating sentry_onpremise_snuba-outcomes-consumer_1                  ... done
Recreating sentry_onpremise_post-process-forwarder_1                   ... done
Recreating sentry_onpremise_sentry-cleanup_1                           ... done
Recreating sentry_onpremise_ingest-consumer_1                          ... done
Recreating sentry_onpremise_web_1                                      ... done
Recreating sentry_onpremise_subscription-consumer-transactions_1       ... done
Recreating sentry_onpremise_worker_1                                   ... done
Recreating sentry_onpremise_subscription-consumer-events_1             ... done
Recreating sentry_onpremise_cron_1                                     ... done
Recreating sentry_onpremise_nginx_1                                    ... done
root@tabll-server:/home/tabll/Sentry/onpremise# git stash drop stash@{0}
丢弃了 stash@{0}(37e364e2d4d5659e72c8fb67a45c025e4874ef29)
root@tabll-server:/home/tabll/Sentry/onpremise#

 

2021-04-13 周二

GitLab Runner 404

本机容器内的 GitLab Runner 一直连接不上

image

这是因为容器镜像仓库的 URL 设置冲突了

/etc/gitlab/gitlab.rb 文件中的镜像仓库相关的配置,需要将 registry_external_urlGitLab 通用的 URL 作出区分

registry_external_url ‘http://127.0.0.1

2021-04-14 周三

容器异常退出

在 Linux 中运行容器存在问题,报错:

 standard_init_linux.go:211: exec user process caused exec format error

 

但是在 Windows 中运行容器是完全可以的

原因是因为软件架构问题导致的,确保容器构建时使用的软件包都是 amd64,我里面有一个软件版本是用的 arm 导致的这个问题

2021-04-15 周四

Laravel 路由修改不生效

这确实是因为缓存的原因,使用 php artisan cache:clear

 php artisan route:cache

 

2021-04-16 周五

修复 2021.1 IDE 无法跳转和搜索

JetBrains 全家桶已更新至 2021.1 版本,用了一段时间后发现代码跳转和全局搜索功能无法正常使用了,重启也没有用,这明显是新版本的 BUG,解决方法:

打开 文件->清除缓存

选中 清除文件系统缓存和本地历史记录,点击确认 失效并重新启动

唤醒精灵