Async Task

“Task” is not about “asynchronous processing”.
“Task” is just a task and it is a structure that someone will process the task.
An asynchronous method is a Task (work procedure manual) created by combining Tasks.
Async void absolute use prohibited(except: UI event handler)

The concept of Task.Run is in a nutshell.
“We consider synchronous series of processing as one task”
If combining asynchronous tasks and combining them into one task is an asynchronous method, you may also want to include synchronous processing as one of the tasks. At that time, it is Task.Run that can be used.

Another use is to write an asynchronous lambda expression in Task.Run. This is just like calling the asynchronous method. The only difference from direct call is that “th asynchronous method is explicitly executed in another context.”

rsync

rsync is application software that uses differential encoding to minimize the amount of data transfer and synchronize files and directories between remote site in UNIX sytems. As a unique feature of rsync which is not found in similar programs and protocols, there is a point that transfer with a mirror site is done bidirectionally at most once. rsync displays directory contents and can copy directories and files. Optionally data compression and recursion can also be specified.

The rsync protocol daemon rsyncd uses TCP port number 873 by default. rsync can also be used to synchronize local directories, it can also be used via RSH or SSH remote shell. In the latter case, the rsync client program needs to be installed both locally and remotely.

It is released at GNU General Public License and is free software.

[vagrant@localhost ~]$ sudo lsyncd -nodaemon -log scarce /etc/lsyncd.conf
Error: failure getting absolute path of [/tmp/origin]
Error: Cannot access source directory: /tmp/origin
[vagrant@localhost ~]$ sudo lsyncd -nodaemon -log scarce /etc/lsyncd.conf

what is xinetd?

xinetd is an Internet super server replacing the inetd daemon. For inetd, the setting of the service to be provided was done in /etc/intd.conf, but in xinetd, setting of services to be provided using /etc/xinetd.conf and files under /etc/xinetd.d to hold.

/etc/xinetd.conf is the default configuration file of xinetd, and each file under /etc/xinetd.d is a configuration file for each service.

[vagrant@localhost ~]$ sudo cat /etc/xinetd.conf
cat: /etc/xinetd.conf: そのようなファイルやディレクトリはありません

なんじゃーーーーーーーーー

edit /etc/lsyncd.conf

default file setting

----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync, but executing moves through on the target.
--
-- For more examples, see /usr/share/doc/lsyncd*/examples/
-- 
-- sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"}

[vagrant@localhost ~]$ sudo vi /etc/lsyncd.conf

settings {
	logfile = "/var/log/lsyncd/lsyncd.log",
	statusFile = "/var/log/lsyncd/lsyncd.status"
}

sync {
	default.rsync,
	source = "/tmp/origin",
	target = "/tmp/target",
	rsync = {
		archive = true,
		compress = true
	},
	delete = false
}

[vagrant@localhost ~]$ mkdir -m 700 /var/log/lsyncd && chcon -R -u system_u “/var/log/lsyncd”
mkdir: ディレクトリ `/var/log/lsyncd’ を作成できません: ファイルが存在します
なにいいいいいいいいいいいいいいい

[vagrant@localhost ~]$ systemctl restart rsyslog
-bash: systemctl: コマンドが見つかりません
[vagrant@localhost ~]$ systemctl start lsyncd
-bash: systemctl: コマンドが見つかりません

なにいいいいいいいいいいいいいいいいいいいいいいいい

cp -ip ${file_name}

-i option: to confirm when overwriting is necessary
In contrast to the -f option, sometimes you want to check whether it will be overwritten. When dealing with important files, overwriting is a fatal injury.

$cp -i after original copy

“yes or no” confirmation will come out.

cp -i

In recent distributions this is the default as well. If it is not set it may be set with alias.

-p opiton(-parents): copy each directory structure
With the usual cp command, you can not copy in subdirectories. In that case, use the “-P” option.

Running without options in the example will normally just let file.txt go into the directory. Using the –parents option you will find that you can copy the directory structure as is.

[vagrant@localhost ~]$ cp -ip /etc/lsyncd.conf{,.org}
cp: cannot create regular file `/etc/lsyncd.conf.org’: 許可がありません
[vagrant@localhost ~]$ sudo cp -ip /etc/lsyncd.conf{,.org}

install Lsyncd on CentOS

Introduction of Extra Packages for Enterprise Linux (EPEL).

/etc/yum.repos.d/epel.repo

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[vagrant@localhost ~]$ sudo sed -i -e “s/enabled=1/enabled=0/” /etc/yum.repos.d/epel.repo

[vagrant@localhost ~]$ sudo yum –enablerepo=epel install lsyncd
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Determining fastest mirrors
epel/metalink | 7.6 kB 00:00
* base: ftp-srv2.kddilabs.jp
* epel: mirror01.idc.hinet.net
* extras: ftp-srv2.kddilabs.jp
* remi-safe: ftp.riken.jp
* updates: ftp-srv2.kddilabs.jp
base | 3.7 kB 00:00
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:12
extras | 3.4 kB 00:00
jenkins | 2.9 kB 00:00
jenkins/primary_db | 126 kB 00:01
mariadb | 2.9 kB 00:00
mysql-connectors-community | 2.5 kB 00:00
mysql-tools-community | 2.5 kB 00:00
mysql56-community | 2.5 kB 00:00
nginx | 2.9 kB 00:00
nodesource | 2.5 kB 00:00
remi-safe | 3.0 kB 00:00
remi-safe/primary_db | 1.2 MB 00:02
updates | 3.4 kB 00:00
依存性の解決をしています
–> トランザクションの確認を実行しています。
—> Package lsyncd.x86_64 0:2.1.5-0.el6 will be インストール
–> 依存性解決を終了しました。

依存性を解決しました

================================================================================
パッケージ アーキテクチャ バージョン リポジトリー 容量
================================================================================
インストールしています:
lsyncd x86_64 2.1.5-0.el6 epel 73 k

トランザクションの要約
================================================================================
インストール 1 パッケージ

総ダウンロード容量: 73 k
インストール済み容量: 205 k
これでいいですか? [y/N]y
パッケージをダウンロードしています:
lsyncd-2.1.5-0.el6.x86_64.rpm | 73 kB 00:00
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
インストールしています : lsyncd-2.1.5-0.el6.x86_64 1/1
Verifying : lsyncd-2.1.5-0.el6.x86_64 1/1

インストール:
lsyncd.x86_64 0:2.1.5-0.el6

完了しました!

ほう^^

lsyncd

Lyscd – Live Syncing (Mirror) Daemon uses inotify to detect that a change has been made to the directory to be monitored, and uses rsync etc. to synchronize that changed files.

You can set it to call another tool instead of rsync.

Since synchronization is done on a file basis, it is not suitable for duplicating databases and the like.

– Regarding file updates monitored by kernel inotify, use API to monitor updates.
– Implement rsync to the mirror destination rsyncd (default is to use rsync) when file update occurs, realizing directory mirroring in real time.
– In addition to the default rsync, it is possible to use DRDB, GlusterFS, BindFS, etc. as a synchronization method.