php – Add wordpress wp_mail SMTP configuration but not in wp-config

I have added E-Mail SMTP settings to wordpress wp-config.php file and now wordpress is sending emails as expected. the solution was found here

But i am building a plugin, where i prefer to add the SMTP configuration in the wordpress backend, without adding the SMTP setting each time manually in the wp-config.php file. So the account credentials will be saved in wp_options.

What is the best practice to add those settings in my plwithout touching the wp-config.php?

performance tuning – how to speed up / fix this Ubuntu Apache MySQL Server Configuration?

I got new to the project, my predecessor is far gone and I’m left on my own.

Currently the MySQL-database seems super slow and after checking some variables and values I cannot identify the problem on my own. I’ve also run mysqltuner but strangly it reports that the innodb engine is deactivated which isn’t for sure since it’s the default engine and the status is fine, so I don’t think I can trust the results of mysqltuner.

Right now for example “show processlist” is empty, but I can see a lot of mysqld tasks running with htop (see screenshot) and a lot of memory usage. Does this look normal to you experts? I would kill these tasks but I really would like to find the reason for them first. Since I’m not sure which pieces of information are of interest I’ve provides the innoDB engine status (attached below) and the InnoDB-related variables (also attached below).

Thank you for your time and effort, I really need to get more into this kind of stuff so any help and ideas would be wonderful.

=====================================
2020-09-17 17:58:44 0x7ef90762f700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 41 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 42194 srv_active, 0 srv_shutdown, 42152 srv_idle
srv_master_thread log flush and writes: 0
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 125254
OS WAIT ARRAY INFO: signal count 124576
RW-shared spins 4411, rounds 5237, OS waits 830
RW-excl spins 17356, rounds 501666, OS waits 16806
RW-sx spins 4095, rounds 121485, OS waits 3998
Spin rounds per wait: 1.19 RW-shared, 28.90 RW-excl, 29.67 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 9920862
Purge done for trx's n:o < 9920862 undo n:o < 0 state: running but idle
History list length 26
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421099207277976, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421099207277120, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421099207276264, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: (0, 0, 0, 0) , aio writes: (0, 0, 0, 0) ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 748
419651 OS file reads, 9621589 OS file writes, 1888824 OS fsyncs
0.32 reads/s, 14020 avg bytes/read, 60.07 writes/s, 13.66 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 3, seg size 5, 34 merges
merged operations:
 insert 12, delete mark 38, delete 9
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 3112859, node heap has 169 buffer(s)
Hash table size 3112859, node heap has 111 buffer(s)
Hash table size 3112859, node heap has 193 buffer(s)
Hash table size 3112859, node heap has 209 buffer(s)
Hash table size 3112859, node heap has 366 buffer(s)
Hash table size 3112859, node heap has 109 buffer(s)
Hash table size 3112859, node heap has 200 buffer(s)
Hash table size 3112859, node heap has 214 buffer(s)
14711.84 hash searches/s, 379.26 non-hash searches/s
---
LOG
---
Log sequence number          287517725947
Log buffer assigned up to    287517725947
Log buffer completed up to   287517725947
Log written up to            287517725947
Log flushed up to            287517725947
Added dirty pages up to      287517725947
Pages flushed up to          287508837360
Last checkpoint at           287508837360
6634374 log i/o's done, 50.78 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 12877824000
Dictionary memory allocated 19713366
Buffer pool size   768000
Free buffers       334247
Database pages     432182
Old database pages 159682
Modified db pages  265
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 7, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 410863, created 21319, written 2300114
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 432182, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   96000
Free buffers       41846
Database pages     53957
Old database pages 19937
Modified db pages  265
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 7, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 410863, created 21319, written 2300114
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 432182, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   96000
Free buffers       41846
Database pages     53957
Old database pages 19937
Modified db pages  39
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 51648, created 2309, written 330263
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 53957, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
---BUFFER POOL 1
Buffer pool size   96000
Free buffers       42236
Database pages     53561
Old database pages 19791
Modified db pages  2
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 51174, created 2387, written 243880
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 53561, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
---BUFFER POOL 2
Buffer pool size   96000
Free buffers       42635
Database pages     53178
Old database pages 19650
Modified db pages  26
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 50955, created 2223, written 253853
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 53178, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
---BUFFER POOL 3
Buffer pool size   96000
Free buffers       41500
Database pages     54292
Old database pages 20061
Modified db pages  31
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 51459, created 2833, written 256415
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 54292, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
---BUFFER POOL 4
Buffer pool size   96000
Free buffers       41683
Database pages     54126
Old database pages 19997
Modified db pages  38
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 50921, created 3205, written 288400
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 54126, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
---BUFFER POOL 5
Buffer pool size   96000
Free buffers       40936
Database pages     54876
Old database pages 20276
Modified db pages  27
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 2, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 52101, created 2775, written 255132
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 54876, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
---BUFFER POOL 6
Buffer pool size   96000
Free buffers       41276
Database pages     54525
Old database pages 20147
Modified db pages  29
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 2, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 51794, created 2731, written 310088
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 54525, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
---BUFFER POOL 7
Buffer pool size   96000
Free buffers       42135
Database pages     53667
Old database pages 19823
Modified db pages  73
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 50811, created 2856, written 362083
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 53667, unzip_LRU len: 0
I/O sum(0):cur(0), unzip sum(0):cur(0)
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=2007245, Main thread ID=139610143446784 , state=sleeping
Number of rows inserted 4368, updated 119517, deleted 4866, read 210363302
0.22 inserts/s, 2.54 updates/s, 0.07 deletes/s, 14802.22 reads/s
Number of system rows inserted 58, updated 367, deleted 0, read 4466273
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 42.46 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

INNODB VARIABLES

| innodb_adaptive_flushing                 | ON                     |
| innodb_adaptive_flushing_lwm             | 10                     |
| innodb_adaptive_hash_index               | ON                     |
| innodb_adaptive_hash_index_parts         | 8                      |
| innodb_adaptive_max_sleep_delay          | 150000                 |
| innodb_api_bk_commit_interval            | 5                      |
| innodb_api_disable_rowlock               | OFF                    |
| innodb_api_enable_binlog                 | OFF                    |
| innodb_api_enable_mdl                    | OFF                    |
| innodb_api_trx_level                     | 0                      |
| innodb_autoextend_increment              | 64                     |
| innodb_autoinc_lock_mode                 | 2                      |
| innodb_buffer_pool_chunk_size            | 1572864000             |
| innodb_buffer_pool_dump_at_shutdown      | ON                     |
| innodb_buffer_pool_dump_now              | OFF                    |
| innodb_buffer_pool_dump_pct              | 25                     |
| innodb_buffer_pool_filename              | ib_buffer_pool         |
| innodb_buffer_pool_in_core_file          | ON                     |
| innodb_buffer_pool_instances             | 8                      |
| innodb_buffer_pool_load_abort            | OFF                    |
| innodb_buffer_pool_load_at_startup       | ON                     |
| innodb_buffer_pool_load_now              | OFF                    |
| innodb_buffer_pool_size                  | 12582912000            |
| innodb_change_buffer_max_size            | 25                     |
| innodb_change_buffering                  | all                    |
| innodb_checksum_algorithm                | crc32                  |
| innodb_cmp_per_index_enabled             | OFF                    |
| innodb_commit_concurrency                | 0                      |
| innodb_compression_failure_threshold_pct | 5                      |
| innodb_compression_level                 | 6                      |
| innodb_compression_pad_pct_max           | 50                     |
| innodb_concurrency_tickets               | 5000                   |
| innodb_data_file_path                    | ibdata1:12M:autoextend |
| innodb_data_home_dir                     |                        |
| innodb_deadlock_detect                   | ON                     |
| innodb_dedicated_server                  | OFF                    |
| innodb_default_row_format                | dynamic                |
| innodb_directories                       |                        |
| innodb_disable_sort_file_cache           | OFF                    |
| innodb_doublewrite                       | ON                     |
| innodb_doublewrite_batch_size            | 0                      |
| innodb_doublewrite_dir                   |                        |
| innodb_doublewrite_files                 | 2                      |
| innodb_doublewrite_pages                 | 4                      |
| innodb_fast_shutdown                     | 1                      |
| innodb_file_per_table                    | ON                     |
| innodb_fill_factor                       | 100                    |
| innodb_flush_log_at_timeout              | 1                      |
| innodb_flush_log_at_trx_commit           | 1                      |
| innodb_flush_method                      | fsync                  |
| innodb_flush_neighbors                   | 0                      |
| innodb_flush_sync                        | ON                     |
| innodb_flushing_avg_loops                | 30                     |
| innodb_force_load_corrupted              | OFF                    |
| innodb_force_recovery                    | 0                      |
| innodb_fsync_threshold                   | 0                      |
| innodb_ft_aux_table                      |                        |
| innodb_ft_cache_size                     | 8000000                |
| innodb_ft_enable_diag_print              | OFF                    |
| innodb_ft_enable_stopword                | ON                     |
| innodb_ft_max_token_size                 | 84                     |
| innodb_ft_min_token_size                 | 3                      |
| innodb_ft_num_word_optimize              | 2000                   |
| innodb_ft_result_cache_limit             | 2000000000             |
| innodb_ft_server_stopword_table          |                        |
| innodb_ft_sort_pll_degree                | 2                      |
| innodb_ft_total_cache_size               | 640000000              |
| innodb_ft_user_stopword_table            |                        |
| innodb_idle_flush_pct                    | 100                    |
 innodb_idle_flush_pct                    | 100                    |
| innodb_io_capacity                       | 200                    |
| innodb_io_capacity_max                   | 2000                   |
| innodb_lock_wait_timeout                 | 50                     |
| innodb_log_buffer_size                   | 16777216               |
| innodb_log_checksums                     | ON                     |
| innodb_log_compressed_pages              | ON                     |
| innodb_log_file_size                     | 50331648               |
| innodb_log_files_in_group                | 2                      |
| innodb_log_group_home_dir                | ./                     |
| innodb_log_spin_cpu_abs_lwm              | 80                     |
| innodb_log_spin_cpu_pct_hwm              | 50                     |
| innodb_log_wait_for_flush_spin_hwm       | 400                    |
| innodb_log_write_ahead_size              | 8192                   |
| innodb_lru_scan_depth                    | 1024                   |
| innodb_max_dirty_pages_pct               | 90.000000              |
| innodb_max_dirty_pages_pct_lwm           | 10.000000              |
| innodb_max_purge_lag                     | 0                      |
| innodb_max_purge_lag_delay               | 0                      |
| innodb_max_undo_log_size                 | 1073741824             |
| innodb_monitor_disable                   |                        |
| innodb_monitor_enable                    |                        |
| innodb_monitor_reset                     |                        |
| innodb_monitor_reset_all                 |                        |
| innodb_numa_interleave                   | OFF                    |
| innodb_old_blocks_pct                    | 37                     |
| innodb_old_blocks_time                   | 1000                   |
| innodb_online_alter_log_max_size         | 134217728              |
| innodb_open_files                        | 4000                   |
| innodb_optimize_fulltext_only            | OFF                    |
| innodb_page_cleaners                     | 4                      |
| innodb_page_size                         | 16384                  |
| innodb_parallel_read_threads             | 4                      |
| innodb_print_all_deadlocks               | OFF                    |
| innodb_print_ddl_logs                    | OFF                    |
| innodb_purge_batch_size                  | 300                    |
| innodb_purge_rseg_truncate_frequency     | 128                    |
| innodb_purge_threads                     | 4                      |
| innodb_random_read_ahead                 | OFF                    |
| innodb_read_ahead_threshold              | 56                     |
| innodb_read_io_threads                   | 4                      |
| innodb_read_only                         | OFF                    |
| innodb_redo_log_archive_dirs             |                        |
| innodb_redo_log_encrypt                  | OFF                    |
| innodb_replication_delay                 | 0                      |
| innodb_rollback_on_timeout               | OFF                    |
| innodb_rollback_segments                 | 128                    |
| innodb_sort_buffer_size                  | 1048576                |
| innodb_spin_wait_delay                   | 6                      |
| innodb_spin_wait_pause_multiplier        | 50                     |
| innodb_stats_auto_recalc                 | ON                     |
| innodb_stats_include_delete_marked       | OFF                    |
| innodb_stats_method                      | nulls_equal            |
| innodb_stats_on_metadata                 | OFF                    |
| innodb_stats_persistent                  | ON                     |
| innodb_stats_persistent_sample_pages     | 20                     |
| innodb_stats_transient_sample_pages      | 8                      |
| innodb_status_output                     | OFF                    |
| innodb_status_output_locks               | OFF                    |
| innodb_strict_mode                       | ON                     |
| innodb_sync_array_size                   | 1                      |
| innodb_sync_spin_loops                   | 30                     |
| innodb_table_locks                       | ON                     |
| innodb_temp_data_file_path               | ibtmp1:12M:autoextend  |
| innodb_temp_tablespaces_dir              | ./#innodb_temp/        |
| innodb_thread_concurrency                | 0                      |
| innodb_thread_sleep_delay                | 10000                  |
| innodb_tmpdir                            |                        |
| innodb_undo_directory                    | ./                     |
| innodb_undo_log_encrypt                  | OFF                    |
| innodb_undo_log_truncate                 | ON                     |
| innodb_undo_tablespaces                  | 2                      |
| innodb_use_native_aio                    | ON                     |
| innodb_validate_tablespace_paths         | ON                     |
| innodb_version                           | 8.0.21                 |
| innodb_write_io_threads                  | 4                      |
(!(htop screenshot)(1))(1)                                                                    


  (1): https://i.stack.imgur.com/Y4JV8.png

postgresql – How can I determine what’s a better configuration for my app?

I’m currently using Postgres 12 on AWS RDS and am using their default configuration for the database.

I use a gem called PgHero that advises me to use PGTune to improve the efficiency of the database. After inserting my inputs on https://pgtune.leopard.in.ua/

# DB Version: 12
# OS Type: linux
# DB Type: web
# Total Memory (RAM): 7 GB
# CPUs num: 2
# Data Storage: ssd

It gives me the advice to update my DB configuration to:

max_connections = 200  # AWS has: LEAST({DBInstanceClassMemory/9531392},5000)
shared_buffers = 1792MB  # AWS has {DBInstanceClassMemory/32768}
effective_cache_size = 5376MB # AWS has {DBInstanceClassMemory/16384}
maintenance_work_mem = 448MB  # AWS has GREATEST({DBInstanceClassMemory*1024/63963136},65536)
checkpoint_completion_target = 0.7  # AWS has 0.9
wal_buffers = 16MB # AWS is not set
default_statistics_target = 100  # AWS is not set
random_page_cost = 1.1  # AWS is not set
effective_io_concurrency = 200 # AWS is not set
work_mem = 9175kB # AWS is not set
min_wal_size = 1GB  # AWS is 192MB
max_wal_size = 4GB  # AWS is 2048MB
max_worker_processes = 2 # AWS is 8
max_parallel_workers_per_gather = 1 # AWS is not set
max_parallel_workers = 2 # AWS is not set
max_parallel_maintenance_workers = 1 # AWS is not set

I’m not sure whether to use PGTune or just leave RDS defaults? How does one typically determine if there is performance updates? Am I in over my head?

time – What triggers the change of value of the NTP configuration file?

The NTP configuration file is in the location /etc/ntp.conf. What triggers the modification of its values?

ntp.conf

server time.asia.apple.com

Everytime I awake or restart my computer, it sets to a different value.

What triggers the change of value of the NTP configuration file?

What server configuration should i use?

I need a good server configuration for a web application.
Around ~120 people will chat with each other and share pictures, video and links. What server configuration should I use for this given situatuion? Thank you for your answers!

configuration – How do I make PostgreSQL not log specific errors?

ERROR: deadlock detected at character 13

My PG log is full of this, but the thing is, I already handle it (after years of frustrations) in my application. I detect them and repeat until they go through. So, there is no longer any reason for me to see these specific “errors”, and the only thing they accomplish now is to obscure the remaining actual errors!

Therefore, I wonder if there is some way to prevent PG from logging specifically those “deadlock detected” errors. I don’t want other errors of the same “significance” to also be suppressed; only those ones, since I’m aware that they happen and already handle them.

I could not find any such directive in the manual. log_min_messages and log_min_error_statement are both too generic and, if I changed them, would potentially suppress other errors which I haven’t figured out how to handle.

The fact that these deadlocks are actually considered/called “errors” make me feel uncomfortable. Even though I do handle them, they seem to be utterly impossible to avoid in real life. Sooner or later, usually when a lot of things are executed at the same time/in parallel, they will happen. But once again, my code detects it and waits and repeats the query over and over until it goes through, so I no longer consider these to be errors that should be logged.

I hope this isn’t impossible without me switching from the “plain” text log to the CSV log and then import it back into my database and exclude these errors that way. It seems like this kind of error log should be plaintext file-based, and eventlog (Windows) is like a joke. (Impossible to navigate/extract anything useful from.)

magento2 – Add link in custom carrier configuration

I developed a custom carrier module following Magento2 documentation here and I want to add in the admin configuration section a link to open an external page in a new tab.

I saw there is a type=”link” field and I’ve done this so far but I don’t know how to add the href.
Carrier Settings
This is on my Vendor/Module/etc/adminhtml/system.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="carriers" translate="label" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1">
            <group id="mycarrier" translate="label" type="text" sortOrder="900" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Custom Shipping Module</label>
                <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Enabled</label>
                    <source_model>MagentoConfigModelConfigSourceYesno</source_model>
                </field>
                <field id="title" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Title</label>
                </field>
                <field id="sallowspecific" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Ship to Applicable Countries</label>
                    <frontend_class>shipping-applicable-country</frontend_class>
                    <source_model>MagentoShippingModelConfigSourceAllspecificcountries</source_model>
                </field>
                <field id="specificcountry" translate="label" type="multiselect" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Ship to Specific Countries</label>
                    <source_model>MagentoDirectoryModelConfigSourceCountry</source_model>
                    <can_be_empty>1</can_be_empty>
                </field>
                <field id="showmethod" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Show Method if Not Applicable</label>
                    <source_model>MagentoConfigModelConfigSourceYesno</source_model>
                    <frontend_class>shipping-skip-hide</frontend_class>
                </field>
                <field id="my_rates" translate="label" type="link" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Configure your custom checkout calculated rates</label>
                </field>
            </group>
        </section>
    </system>
</config>

And in my Vendor/Module/etc/config.xml file I have

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <carriers>
            <mycarrier>
                <active>1</active>
                <title>My Custom Shipping Method</title>
                <sallowspecific>0</sallowspecific>
                <showmethod>no</showmethod>
                <my_rates>Go to externalpage.com settings</my_rates>
                <model>VendorModuleModelCarrierMyCarrier</model>
            </mycarrier>
        </carriers>
    </default>
</config>

Also, I need to access to Magento’s storeManager object as part of the parameters I’ll send in the link, so I need to be able to access to $this->_storeManager->getStore()->getBaseUrl(); to add it in the href.

Thanks

centos7 – CentOS 7 systemd.exec configuration: alternatives to LogsDirectory & CacheDirectory?

On a CentOS Linux 7.8 system, if I create a systemd service configuration file and include LogsDirectory and/or CacheDirectory in the [Service] section, then do a systemctl daemon-reload, the following errors are printed in /var/log/messages:

Sep  8 13:14:50 model systemd: [/etc/systemd/system/hugo-sbml.service:18] Unknown lvalue 'CacheDirectory' in section 'Service'
Sep  8 13:14:50 model systemd: [/etc/systemd/system/hugo-sbml.service:19] Unknown lvalue 'LogsDirectory' in section 'Service'

The man page for systemd.exec is confusing: it does not document LogsDirectory and CacheDirectory, but it does list error codes associated with failures involving them. Googling around, those settings appear to be commonly used in systemd configuration files.

Is there a replacement for the LogsDirectory and CacheDirectory settings in a systemd service configuration file on CentOS 7? Or to put it another way, what are we supposed to do if we need log and cache directories to be created?

entities – How should a custom configuration entity define a dependency on other configuration?

In a custom module I am defining a defaults Configuration entity that references a role.
I would like to define a dependency on the role. This is my first attempt.

public function calculateDependencies() {
  $this->dependencies = parent::calculateDependencies();
  $this->addDependency('module', 'user');
  if (isset($this->role_id)) {
    $this->addDependency('config', "user.role.{$this->role_id}");
  }
  return $this; // Also tried return $this->dependencies;
}

The Drupal documentation on dependencies references the Block configuration class that looks very similar:

  public function calculateDependencies() {
    parent::calculateDependencies();
    $this->addDependency('theme', $this->theme);
    return $this;
  }

However I am seeing an error shown below when trying to save the entity.The backtrace indicates it is coming from the attempt to add a dependency on the user module. I chose to add that dependency by taking an example from system.action.user_add_role_action.administrator.

PHP Error: Cannot use object of type Drupal/my_module/Entity/MyAccessDefaults as array in /app/web/core/lib/Drupal/Core/Entity/DependencyTrait.php on line 32

For example I am trying to test with this code:

$values = (
  'id' => 'administrator', 'label' => 'Administrator role grants', 
  'grant_type' => 'role', 'role_id' => "administrator", 
  'grants' => ('grant_view' => 1)
);
$default_admin_config = Drupal::entityTypeManager()->getStorage('my_entity')->create($values);
$default_admin_config->save();

configuration – is it possible to install elastic search in localhost Magento 2.3.4 p2 version

I have installed Elasticsearch in my Linux Mint & It’s working fine. Here is the steps.

Run the below command to Install Elasticsearch In locally.

Download and install the public signing key :

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

Installing from the APT repositoryedit

You may need to install the apt-transport-https package on Debian before proceeding :

sudo apt-get install apt-transport-https

Save the repository definition to /etc/apt/sources.list.d/elastic-7.x.list :

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

You can install the Elasticsearch Debian package with :

sudo apt-get update && sudo apt-get install elasticsearch

Elasticsearch is not started automatically after installation. How to start and stop Elasticsearch depends on whether your system uses SysV init or systemd (used by newer distributions).

ps -p 1

Running Elasticsearch with SysV init : Use the update-rc.d command to configure Elasticsearch to start automatically when the system boots up :

sudo update-rc.d elasticsearch defaults 95 10

Elasticsearch can be started and stopped using the service command :

sudo -i service elasticsearch start

sudo -i service elasticsearch stop

Configure Apache and Elasticsearch : Set up a proxy (Set up a proxy for Apache 2.4)

Enable mod_proxy as follows :

a2enmod proxy_http or sudo a2enmod proxy_http

Use a text editor to open /etc/apache2/sites-available/000-default.conf

Add the following directive at the top of the file :

Listen 8080

Add the following at the bottom of the file :

<VirtualHost *:8080>
    ProxyPass "/" "http://localhost:9200/"
    ProxyPassReverse "/" "http://localhost:9200/"
</VirtualHost>

Restart Apache :

service apache2 restart or sudo service apache2 restart

Verify the proxy works by entering the following command :

For example, if your proxy uses port 8080:

curl -i http://localhost:8080/_cluster/health

If curl request success then messages display like below :

HTTP/1.1 200 OK
Date: Sun, 23 Aug 2020 06:05:56 GMT
Server: Apache/2.4.18 (Ubuntu)
content-type: application/json; charset=UTF-8
content-length: 389

{“cluster_name”:”elasticsearch”,”status”:”yellow”,”timed_out”:false,”number_of_nodes”:1,”number_of_data_nodes”:1,”active_primary_shards”:1,”active_shards”:1,”relocating_shards”:0,”initializing_shards”:0,”unassigned_shards”:1,”delayed_unassigned_shards”:0,”number_of_pending_tasks”:0,”number_of_in_flight_fetch”:0,”task_max_waiting_in_queue_millis”:0,”active_shards_percent_as_number”:50.0}

Go to Admin Panel -> Stores -> Settings -> Configuration -> Catalog -> Catalog Search. Change the settings like below.

Search Engine : Search Engine7

Elasticsearch Server Hostname : localhost

Elasticsearch Server Port : 8080

Elasticsearch Index Prefix : magento2

Enable Elasticsearch HTTP Auth : No

Elasticsearch Server Timeout : 15

Now save the configuration & run below cache clean command.

php bin/magento cache:clean

Now click on Test Connection button.

After successful you will receive Successful! Test again? in Test Connection button.

Ref : Dev Docs & Elasticsearch

For More Click here