Most recently, Github Ruby team extracted internal functionality to disable joining queries when an association crossed multiple databases. Prior to our work in this area, Rails had no support for handling associations that spanned across clusters; teams had to write SQL to achieve this.
The overall implementation is relatively small. To accomplish disabling joins, we added an option to has_many :through associations called disable_joins. When set to true for an association, Rails will generate separate queries for each database rather than a join query.
resource "ldap_object" "foo" { # DN must be complete (no RDN!) dn = "uid=foo,dc=example,dc=com"
# classes are specified as an array object_classes = [ "inetOrgPerson", "posixAccount", ]
# attributes are specified as a set of 1-element maps attributes = [ { sn = "10" }, { cn = "bar" }, { uidNumber = "1234" }, { gidNumber = "1234" }, { homeDirectory = "/home/billy" }, { loginShell = "/bin/bash" }, # when an attribute has multiple values, it must be specified multiple times { mail = "[email protected]" }, { mail = "[email protected]" }, ] }
Run
Terraform Init
1
terraform init
It will download the Terraform LDAP Provider binary.
Terraform apply
1
terraform apply
It will dispaly the execute plan and wait for your make yes or no.
Then yes to create ldap objects.
Import
Import and create .tf file by run ./import.sh command.
1
./import.sh uid=foo,dc=example,dc=com
It will import LDAP object(uid=foo,dc=example,dc=com) to Terraform State(terraform.tfstate) and auto create the ldap_object.foo.tf file.
You can continue to maintain that file and run terraform apply command to manage the exist LDAP objects without copying & pasting from Terraform State(terraform.tfstate).
The Annotate (aka AnnotateModels) gem annotating Rails classes with schema and routes info by adding a comment summarizing the current schema to the top or bottom of each of your…
The Bullet gem is designed to help you increase your application’s performance by reducing the number of queries it makes. It will watch your queries while you develop your application and notify you when you should add eager loading (N+1 queries), when you’re using eager loading that isn’t necessary and when you should use counter cache.
The marginalia gem attaching comments to your ActiveRecord queries. By default, it adds the application, controller, and action names as a comment at the end of each query.
This helps when searching log files for queries, and seeing where slow queries came from.
Since there are two ways to configure your connection (using config/database.yml or using an environment variable ENV['DATABASE_URL']) it is important to understand how they can interact.
If you look at the options of the application generator, you will see that one of the options is named --database. This option allows you to choose an adapter from a list of the most used relational databases. You can even run the generator repeatedly:
1
$ cd .. && rails new blog --database=mysql
When you confirm the overwriting of the config/database.yml file, your application will be configured for MySQL instead of SQLite. Detailed examples of the common database connections are below.
Print Configuration
1 2 3 4 5 6 7 8 9 10 11
# Current database configuration > ActiveRecord::Base.connection_db_config
# DEPRECATION WARNING: connection_config is deprecated and will be removed from Rails 6.2 (Use connection_db_config instead) # > ActiveRecord::Base.connection_config
# Current database configuration > Rails.configuration.database_configuration[Rails.env]
# All database configuration > Rails.configuration.database_configuration
Connection Preference
If you have an empty config/database.yml file but your ENV['DATABASE_URL'] is present, then Rails will connect to the database via your environment variable ENV['DATABASE_URL'].
If you have a config/database.yml but no ENV['DATABASE_URL'] then this file will be used to connect to your database:
If you have both config/database.yml and ENV['DATABASE_URL'] set then Rails will merge the configuration together. To better understand this we must see some examples.
When duplicate connection information is provided the environment variable will take precedence
If non-duplicate information is provided you will get all unique values, environment variable still takes precedence in cases of any conflicts.
The only way to explicitly not use the connection information in ENV['DATABASE_URL'] is to specify an explicit URL connection using the url sub key:
Here the connection information in ENV['DATABASE_URL'] is ignored, note the different adapter and database name.
(Recommended) Embed ENV[‘DATABASE_URL’] in config/database.yml
Since it is possible to embed ERB in your config/database.yml it is best practice to explicitly show you are using the ENV['DATABASE_URL'] to connect to your database. This is especially useful in production since you should not commit secrets like your database password into your source control (such as Git).
If you choose to use MySQL or MariaDB instead of the shipped SQLite3 database, your config/database.yml will look a little different. Here’s the development section:
If your development database has a root user with an empty password, this configuration should work for you. Otherwise, change the username and password in the development section as appropriate.
If your MySQL version is 5.5 or 5.6 and want to use the utf8mb4 character set by default, please configure your MySQL server to support the longer key prefix by enabling innodb_large_prefix system variable.
Advisory Locks are enabled by default on MySQL and are used to make database migrations concurrent safe. You can disable advisory locks by setting advisory_locks to false:
By default Active Record uses database features like prepared statements and advisory locks. You might need to disable those features if you’re using an external connection pooler like PgBouncer:
Ifenabled,ActiveRecordwillcreateupto1000 preparedstatementsperdatabaseconnectionbydefault.Tomodifythisbehavioryoucanset`statement_limit`to a different value:
The more prepared statements in use: the more memory your database will require. If your PostgreSQL database is hitting memory limits, try lowering statement_limit or disabling prepared statements.
# The PostgreSQL adapter works with the native C (https://github.com/ged/ruby-pg) driver. # # Options: # # * <tt>:host</tt> - Defaults to a Unix-domain socket in /tmp. On machines without Unix-domain sockets, # the default is to connect to localhost. # * <tt>:port</tt> - Defaults to 5432. # * <tt>:username</tt> - Defaults to be the same as the operating system name of the user running the application. # * <tt>:password</tt> - Password to be used if the server demands password authentication. # * <tt>:database</tt> - Defaults to be the same as the username. # * <tt>:schema_search_path</tt> - An optional schema search path for the connection given # as a string of comma-separated schema names. This is backward-compatible with the <tt>:schema_order</tt> option. # * <tt>:encoding</tt> - An optional client encoding that is used in a <tt>SET client_encoding TO # <encoding></tt> call on the connection. # * <tt>:min_messages</tt> - An optional client min messages that is used in a # <tt>SET client_min_messages TO <min_messages></tt> call on the connection. # * <tt>:variables</tt> - An optional hash of additional parameters that # will be used in <tt>SET SESSION key = val</tt> calls on the connection. # * <tt>:insert_returning</tt> - An optional boolean to control the use of <tt>RETURNING</tt> for <tt>INSERT</tt> statements # defaults to true. # # Any further options are used as connection parameters to libpq. See # https://www.postgresql.org/docs/current/static/libpq-connect.html for the # list of parameters. # # In addition, default connection parameters of libpq can be set per environment variables. # See https://www.postgresql.org/docs/current/static/libpq-envars.html .
Configuring an SQLite3 Database
Rails comes with built-in support for SQLite3, which is a lightweight serverless database application. While a busy production environment may overload SQLite, it works well for development and testing. Rails defaults to using an SQLite database when creating a new project, but you can always change it later.
Here’s the section of the default configuration file (config/database.yml) with connection information for the development environment:
Rails uses an SQLite3 database for data storage by default because it is a zero configuration database that just works. Rails also supports MySQL (including MariaDB) and PostgreSQL “out of the box”, and has plugins for many database systems. If you are using a database in a production environment Rails most likely has an adapter for it.
Rails 6 provide a command has been added to change database adapter automatically.
Let’s say our app has started with SQLite and now we have to switch to MySQL.
1 2 3 4 5 6
$ rails db:system:change --to=mysql conflict config/database.yml Overwrite /Users/cloudolife/example_app/config/database.yml? (enter "h" for help) [Ynaqdhm] Y force config/database.yml gsub Gemfile gsub Gemfile
Our database.yml is now changed to contain the configuration for MySQL database and the Gemfile also gets updated automatically with addition of mysql2 gem in place of sqlite3.
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.
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.
Developing apps today requires so much more than writing code. Multiple languages, frameworks, architectures, and discontinuous interfaces between tools for each lifecycle stage creates enormous complexity.
Docker simplifies and accelerates your workflow, while giving developers the freedom to innovate with their choice of tools, application stacks, and deployment environments for each project.
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
# 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.
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.
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.