Cloud-oriented Life

Cloud Native Technology Improves Lives

Resize XFS disk partition size

XFS is a high-performance journaling file system created by Silicon Graphics, Inc. XFS is particularly proficient at parallel IO due to its allocation group based design. This enables extreme scalability of IO threads, filesystem bandwidth, file and filesystem size when spanning multiple storage devices.

GNU Parted is a program for creating and manipulating partition tables.

This article describe how to use parted and xfs_growfs to resize XFS disk partition size dynamically.

Read more »

SSR-Prerender

ssr-prerender is a wrapper to use Prerender to prerender HTML for SEO. It can run by Docker Compose, Docker or Docker Compose or Shell(Traditional).

Prerender

Prerender is a node server that uses Headless Chrome to render HTML, screenshots, PDFs, and HAR files out of any web page. The Prerender server listens for an http request, takes the URL and loads it in Headless Chrome, waits for the page to finish loading by waiting for the network to be idle, and then returns your content.

It have some advantages:

  • Loosely coupled
    No code or only a small codes need to modify no matter what technical architecture is used within Front-End or Back-End.

  • Out of the box
    Provide cache support, multiple render types(HTML, Image, PDF, HAR), Allowlist, Blacklist, etc.

Deployment Diagram

SSR-Prerender Deployment

Powered by PlantUML

Prerequisites

Configuration

You can change configuration within .env file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# prerender/prerender: Node server that uses Headless Chrome to render a javascript-rendered page as HTML. To be used in conjunction with prerender middleware.
# https://github.com/prerender/prerende
CHROME_FLAGS="--no-sandbox, --headless, --disable-gpu, --remote-debugging-port=9222, --hide-scrollbars"
LOG_REQUESTS=false
PORT=3000

# memory or redis
STORAGE_CACHE=memory

# prerender-redis-cache/prerenderRedisCache.js at master · JonathanBennett/prerender-redis-cache
# https://github.com/JonathanBennett/prerender-redis-cache/blob/master/lib/prerenderRedisCache.js
# REDISTOGO_URL=redis://redis:6379/0
# REDISCLOUD_URL=redis://redis:6379/0
# REDISGREEN_URL=redis://redis:6379/0
REDIS_URL=redis://redis:6379/0

# prerender/prerender-memory-cache: In memory cache for use with Prerender server
# https://github.com/prerender/prerender-memory-cache
CACHE_MAXSIZE=10000
CACHE_TTL=3600

Run

Recommand to run ss-prerender with Docker Compose or Docker.

Docker Compose

1
docker-compose up

Docker

1
docker run -it --rm --name ssr-prerender -p 3000:3000 cloudolife/ssr-prerender:latest

Kubernetes

TBD

Shell

You can run ss-prerender from local shell or within a docker container.

1
node server.js

That’s all.

Test

http://localhost:3000/http://localhost:8080

Upgrade

Google Chrome

This repository has provider a Google Chrome version and will auto install while docker build process. But you can upgrade Google Chrome to the latest version by download and replace google-chrome-stable_current_amd64.deb file with the latest Google Chrome version.

1
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O google-chrome-stable_current_amd64.deb

Then, run command docker build . or docker-compose buiid to rebuild it.

References

[1] prerender/prerender: Node server that uses Headless Chrome to render a javascript-rendered page as HTML. To be used in conjunction with prerender middleware. - https://github.com/prerender/prerender

[2] Prerender - Dynamic Rendering for Effective JavaScript SEO | Prerender - https://prerender.io/

[3] Prerender - Dynamic Rendering for Effective JavaScript SEO | Prerender - https://prerender.io/documentation

[4] Prerender.com | Headless Chrome In The Cloud to Render HTML, Screenshots, PDFs, and HAR Files - https://prerender.com/

[5] Prerender.com | Documentation - https://prerender.com/documentation

[6] prerender-redis-cache/prerenderRedisCache.js at master · JonathanBennett/prerender-redis-cache - https://github.com/JonathanBennett/prerender-redis-cache/blob/master/lib/prerenderRedisCache.js

[7] prerender/prerender-memory-cache: In memory cache for use with Prerender server - https://github.com/prerender/prerender-memory-cache

[8] Docker - https://www.docker.com/

[9] Docker Compose - https://docs.docker.com/compose/

For security reasons, Alibaba Cloud blocks outbound traffic on TCP port 25 by default. that You cannot connect to external addresses TCP port 25 from Alibaba Cloud Cloud servers (ECS).

Background Information

Blocking the outbound direction of TCP 25 port may affect your connection to the SMTP server of a third-party mail service provider through TCP 25 port to send external mail. If you need to use the cloud server on Alibaba Cloud to send external emails, it is recommended that you use Alibaba Cloud Mail products or use the 465 port provided by a third-party mail service provider.

Note If there are special scenarios, you must use TCP port 25 on the cloud server for external connections. Please submit a port 25 unblocking application in the security management and control platform. Alibaba Cloud will review the application reason you submitted and notify you of the review result by email.

Configuration

Remember to replace the content within {{ }} with your prefer value.

The from_address and user must be the same.

1
2
3
4
5
6
7
8
smtp:
from_address: {{ .Values.smtp.from_address }} # [email protected]
host: smtp.exmail.qq.com
port: 465 # not 25
use_tls: {{ .Values.smtp.use_tls }} # true or false
user: {{ .Values.smtp.user }} # [email protected]
password: {{ .Values.smtp.password }}
enable_replies: false # or true

FAQs

smtp or smtps.

1
The $MAIL_URL is 'smtp://...:465'.  You probably want 'smtps://' (The 's' enables TLS/SSL) since '465' is typically a secure port. undefined 

Use smtps protocols and 465 port instead of smtp and 25.

Error code 501

1
Exception in defer callback: Error: Mail command failed: 501 ϵͳÒÑÇ¿ÖÆ¿ªÆôÕʺÅÉý¼¶ÉèÖã¬ÇëµÇ¼exmail.qq.com°ó¶¨Î¢ÐÅ

This is because Tencent Enterprise Mailbox forced to enable the security certification before send email from client.

You can log in Tencent Enterprise Mailbox Administrator Web UI, find the sender’s account, and edit it to disable enforce secure login option.

References

[1] 腾讯企业邮箱 - https://exmail.qq.com/

[2] TCP 25端口解封申请 - 阿里云 - https://help.aliyun.com/document_detail/56130.html

[3] 阿里云服务器不能发邮件禁用25端口的三种解决方法_weixin_30258027的博客-CSDN博客 - https://blog.csdn.net/weixin_30258027/article/details/95448730?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

Terraform Aliyun Monitor Examples

Examples about using Terraform Alibaba Cloud Provider to manage alarm rules and monitor sites.

Github: https://github.com/CloudoLife/terraform-aliyun-monitor-examples

Read more »

asdf and Node.js Plugin

asdf is a single CLI tool for managing multiple runtime versions. It extend with a simple plugin system to install your favourite language: Dart, Elixir, Flutter, Golang (Go), Java, Node.js, Python, Ruby …

This article is about how to use asdf and Node.js plugin to install multiple Node.js versions on macOS with the Homebrew package manager.

Read more »

OSSImport is a free tool created by the Alibaba Cloud product team to assist with data backup and migration into the Alibaba Cloud Object Storage Service (OSS). Using OSSImport data can be migrated from either local storage or from third party cloud platforms. Currently supported data sources include Qiniu, Baidu BOS, AWS S3, Azure Blob, Youpai Cloud, Tencent Cloud COS, Kingsoft KS3, HTTP, and other OSS buckets.

Read more »

migration_comments

Using MigrationComments, you can simply add comments during your migrations. Or if you already have existing data structures, just add the comments afterwards in a separate migration. And of course you can always modify and delete these comments in later migrations.

So where are these comments used? Firstly, they will be included in your schema.rb dump which is where your IDE (e.g. RubyMine, VS Code) should be learning about your model structure. This means that they’ll be available at any point in your project. Additionally, if you are using the 'annotate’ gem, these comments will be added to the annotations that are generated within your model.rb file.

Read more »

Github or Gitlab use ~/.ssh/id_rsa as the default SSH private key. But sometimes you need more accounts than one for access to Github or Gitlab and similar tools. For example you can have one account for your projects at home and second account for your company.

There are three ways to Use multiple SSH private keys within git commands.

Read more »
0%