影響多い。
https://github.com/fuel/core/wiki/Changelog-v1.6
見つからず。
http://fuelphp.jp/docs/1.6/requirements.html
5.3.2
https://github.com/fuel/core/wiki/Changelog-v1.7
http://fuelphp.jp/docs/1.7/requirements.html
5.5+とある。
https://github.com/fuel/core/wiki/Changelog-v1.8
PHP 7 とある。
また、一部5.6+と。
https://github.com/fuel/core/wiki/Changelog-v1.8.1
PHP7.1とある。
git log –graph –oneline –decorate=full –date=short –format=”%C(yellow)%h%C(reset) %C(magenta)[%ad]%C(reset)%C(auto)%d%C(reset) %s %C(cyan)@%an%C(reset)” remotes/origin/1.8/master
ここで、5.6対応も入っていたりする。
その前は、1.7時台。
https://github.com/fuel/core/commits/1.9/develop
7.2, 7.3が。
PHP5.6 Fuelphp1.8
色々調べると、GuzzleHttpがHTTPSで通信する際に増えるらしい
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@ip-172-31-16-82 centos]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@ip-172-31-16-82 centos]# rpm -qa | grep nss-softokn nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64 nss-softokn-3.14.3-23.3.el6_8.x86_64 [root@ip-172-31-16-82 centos]# php -v PHP 5.5.38 (cli) (built: Mar 1 2018 11:12:35) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies [centos@ip-172-31-16-82 slab-nss]$ cat composer.json { "require": { "aws/aws-sdk-php": "^2.8" } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?php require_once('./vendor/autoload.php'); use Aws\Sns\SnsClient; $arn = "arn:aws:sns:ap-northeast-1:xxxxxx:aws-sdk-nss-dentry-test"; $message = 'dummy message'; $client = SnsClient::factory(array( 'profile' => 'default', 'region' => 'ap-northeast-1', )); for ($i = 0; $i < 100; $i ++) { $result = $client->publish(array( 'TopicArn' => $arn, 'Message' => $message )); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[centos@ip-172-31-16-82 ~]$ sar -v 0 Linux 2.6.32-696.30.1.el6.x86_64 (ip-172-31-16-82.ap-northeast-1.compute.internal) 07/08/2018 _x86_64_ (1 CPU) 07:51:10 AM dentunusd file-nr inode-nr pty-nr 07:51:10 AM 41344 736 7227 5 [centos@ip-172-31-16-82 ~]$ sar -v 0 Linux 2.6.32-696.30.1.el6.x86_64 (ip-172-31-16-82.ap-northeast-1.compute.internal) 07/08/2018 _x86_64_ (1 CPU) 07:51:33 AM dentunusd file-nr inode-nr pty-nr 07:51:33 AM 61344 736 7227 5 [centos@ip-172-31-16-82 ~]$ slabtop -o | grep dentry 48140 48105 99% 0.19K 2407 20 9628K dentry [centos@ip-172-31-16-82 ~]$ slabtop -o | grep dentry 68100 68100 100% 0.19K 3405 20 13620K dentry [centos@ip-172-31-16-82 ~]$ free total used free shared buffers cached Mem: 499996 174200 325796 160 14212 53744 -/+ buffers/cache: 106244 393752 Swap: 1048572 1280 1047292 [centos@ip-172-31-16-82 ~]$ free total used free shared buffers cached Mem: 499996 178176 321820 160 14220 53744 -/+ buffers/cache: 110212 389784 Swap: 1048572 1280 1047292 |
dentunusedが増加し、dentryのslabが増加している。
buffers/cacheが減少している。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php putenv("NSS_SDB_USE_CACHE=yes"); // ★追加 require_once('./vendor/autoload.php'); use Aws\Sns\SnsClient; $arn = "arn:aws:sns:ap-northeast-1:xxxxxx:aws-sdk-nss-dentry-test"; $message = 'dummy message'; $client = SnsClient::factory(array( 'profile' => 'default', 'region' => 'ap-northeast-1', )); for ($i = 0; $i < 100; $i ++) { $result = $client->publish(array( 'TopicArn' => $arn, 'Message' => $message )); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[centos@ip-172-31-16-82 ~]$ sar -v 0 Linux 2.6.32-696.30.1.el6.x86_64 (ip-172-31-16-82.ap-northeast-1.compute.internal) 07/08/2018 _x86_64_ (1 CPU) 07:55:05 AM dentunusd file-nr inode-nr pty-nr 07:55:05 AM 61349 736 7230 5 [centos@ip-172-31-16-82 ~]$ sar -v 0 Linux 2.6.32-696.30.1.el6.x86_64 (ip-172-31-16-82.ap-northeast-1.compute.internal) 07/08/2018 _x86_64_ (1 CPU) 07:55:15 AM dentunusd file-nr inode-nr pty-nr 07:55:15 AM 61349 736 7230 5 [centos@ip-172-31-16-82 ~]$ slabtop -o | grep dentry 68120 68110 99% 0.19K 3406 20 13624K dentry [centos@ip-172-31-16-82 ~]$ slabtop -o | grep dentry 68160 68136 99% 0.19K 3408 20 13632K dentry [centos@ip-172-31-16-82 ~]$ free total used free shared buffers cached Mem: 499996 178300 321696 160 14292 53844 -/+ buffers/cache: 110164 389832 Swap: 1048572 1280 1047292 [centos@ip-172-31-16-82 ~]$ free total used free shared buffers cached Mem: 499996 178300 321696 160 14300 53844 -/+ buffers/cache: 110156 389840 Swap: 1048572 1280 1047292 |
ほぼ増加しなくなったことがわかる。
nss-softokn-3.14.3-23.3.el6_8 の環境でも効果がありそうだ。
コードを追っていくと、内部でphp curlを使っているようだ
1 2 3 4 5 |
if (!extension_loaded('curl')) { // @codeCoverageIgnoreStart throw new RuntimeException('The PHP cURL extension must be installed to use Guzzle.'); // @codeCoverageIgnoreEnd } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[centos@ip-172-31-16-82 slab-nss]$ php -r "phpinfo();" | grep "^curl" -A24 PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Command line code on line 1 curl cURL support => enabled cURL Information => 7.19.7 Age => 3 Features AsynchDNS => No CharConv => No Debug => No GSS-Negotiate => Yes IDN => Yes IPv6 => Yes krb4 => No Largefile => Yes libz => Yes NTLM => Yes SPNEGO => No SSL => Yes SSPI => No Protocols => tftp, ftp, telnet, dict, ldap, ldaps, http, file, https, ftps, scp, sftp Host => x86_64-redhat-linux-gnu SSL Version => NSS/3.27.1 ZLib Version => 1.2.3 libSSH Version => libssh2/1.4.2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[centos@ip-172-31-16-82 slab-nss]$ php -r "print_r(curl_version());" Array ( [version_number] => 463623 [age] => 3 [features] => 1597 [ssl_version_number] => 0 [version] => 7.19.7 [host] => x86_64-redhat-linux-gnu [ssl_version] => NSS/3.27.1 [libz_version] => 1.2.3 [protocols] => Array ( [0] => tftp [1] => ftp [2] => telnet [3] => dict [4] => ldap [5] => ldaps [6] => http [7] => file [8] => https [9] => ftps [10] => scp [11] => sftp ) ) |
NSS/3.27.1 が使われているようだ。
osにinstallされているnss-softknは使われていない?
同じバージョンをインストール
1 2 3 4 5 6 7 8 9 10 11 |
# cd /usr/local/src/ # curl -O https://curl.haxx.se/download/archeology/curl-7.19.7.tar.gz # tar xvzf curl-7.19.7.tar.gz # cd curl-7.19.7 # yum install gcc g++ # yum install nspr-devel # yum install nss-devel # ./configure --with-nss --disable-manual # make |
システムのnssが使われた事の確認と効果の確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
[root@ip-172-31-16-82 curl-7.19.7]# rpm -qa | grep nss nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64 nss-util-3.36.0-1.el6.x86_64 nss-softokn-freebl-devel-3.14.3-23.3.el6_8.x86_64 nss-sysinit-3.36.0-8.el6.x86_64 nss-devel-3.36.0-8.el6.x86_64 openssh-server-5.3p1-123.el6_9.x86_64 nss-util-devel-3.36.0-1.el6.x86_64 nss-softokn-devel-3.14.3-23.3.el6_8.x86_64 nss-3.36.0-8.el6.x86_64 nss-tools-3.36.0-8.el6.x86_64 nss-softokn-3.14.3-23.3.el6_8.x86_64 openssl-1.0.1e-57.el6.x86_64 openssh-5.3p1-123.el6_9.x86_64 openssh-clients-5.3p1-123.el6_9.x86_64 [root@ip-172-31-16-82 curl-7.19.7]# ./src/curl -V curl 7.19.7 (x86_64-unknown-linux-gnu) libcurl/7.19.7 NSS/3.36 Protocols: tftp ftp telnet dict http file https ftps Features: IPv6 Largefile SSL [root@ip-172-31-16-82 curl-7.19.7]# strace -fc -e trace=access ./src/curl -s https://www.google.co.jp/ > /dev/null Process 28940 attached Process 28941 attached Process 28942 attached Process 28943 attached Process 28944 attached Process 28946 attached Process 28945 attached Process 28947 attached Process 28949 attached Process 28948 attached Process 28950 attached Process 28951 attached Process 28953 attached Process 28952 attached % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 0.00 0.000000 0 938 926 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000000 938 926 total [root@ip-172-31-16-82 curl-7.19.7]# NSS_SDB_USE_CACHE=yes strace -fc -e trace=access ./src/curl -s https://www.google.co.jp/ > /dev/null Process 29010 attached Process 29011 attached Process 29012 attached Process 29014 attached Process 29015 attached Process 29017 attached Process 29016 attached Process 29018 attached Process 29020 attached Process 29019 attached Process 29021 attached Process 29022 attached Process 29024 attached Process 29023 attached % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 0.00 0.000000 0 24 12 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000000 24 12 total |
nss-softokn-3.14.3-23.3 で nss-softokn-3.14.3-23.3 が使えているだろうと思われる。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[centos@ip-172-31-16-82 slab-nss]$ sudo yum install wget Loaded plugins: fastestmirror, presto Setting up Install Process Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: ftp.iij.ad.jp Resolving Dependencies --> Running transaction check ---> Package wget.x86_64 0:1.12-10.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================ Package Arch Version Repository Size ================================================================================================================================================================================================================ Installing: wget x86_64 1.12-10.el6 base 484 k Transaction Summary ================================================================================================================================================================================================================ Install 1 Package(s) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[centos@ip-172-31-16-82 slab-nss]$ wget http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/Packages/e/epel-release-6-8.noarch.rpm --2018-07-07 08:34:08-- http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/Packages/e/epel-release-6-8.noarch.rpm Resolving ftp.riken.jp... 134.160.38.1 Connecting to ftp.riken.jp|134.160.38.1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 14540 (14K) [application/x-rpm] Saving to: “epel-release-6-8.noarch.rpm” 100%[======================================================================================================================================================================>] 14,540 --.-K/s in 0.006s 2018-07-07 08:34:08 (2.30 MB/s) - “epel-release-6-8.noarch.rpm” saved [14540/14540] [centos@ip-172-31-16-82 slab-nss]$ sudo rpm -ivh ./epel-release-6-8.noarch.rpm warning: ./epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ########################################### [100%] 1:epel-release ########################################### [100%] |
php5.5を入れるために
1 2 3 4 5 |
[centos@ip-172-31-16-82 slab-nss]$ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm Retrieving http://rpms.famillecollet.com/enterprise/remi-release-6.rpm warning: /var/tmp/rpm-tmp.9t2Bg0: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY Preparing... ########################################### [100%] 1:remi-release ########################################### [100%] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
[centos@ip-172-31-16-82 slab-nss]$ sudo yum install --enablerepo=epel python-pip Loaded plugins: fastestmirror, presto Setting up Install Process Loading mirror speeds from cached hostfile epel/metalink | 7.7 kB 00:00 * base: ftp.iij.ad.jp * epel: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: ftp.iij.ad.jp epel | 3.2 kB 00:00 epel/primary | 3.2 MB 00:00 epel 12515/12515 Resolving Dependencies --> Running transaction check ---> Package python-pip.noarch 0:7.1.0-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================ Package Arch Version Repository Size ================================================================================================================================================================================================================ Installing: python-pip noarch 7.1.0-1.el6 epel 1.5 M Transaction Summary ================================================================================================================================================================================================================ Install 1 Package(s) Total download size: 1.5 M Installed size: 6.6 M Is this ok [y/N]: y Downloading Packages: Setting up and reading Presto delta metadata epel/prestodelta | 770 B 00:00 Processing delta metadata Package(s) data still to download: 1.5 M python-pip-7.1.0-1.el6.noarch.rpm | 1.5 MB 00:00 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 Importing GPG key 0x0608B895: Userid : EPEL (6) <epel@fedoraproject.org> Package: epel-release-6-8.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 Is this ok [y/N]: y Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : python-pip-7.1.0-1.el6.noarch 1/1 Verifying : python-pip-7.1.0-1.el6.noarch 1/1 Installed: python-pip.noarch 0:7.1.0-1.el6 Complete! |
1 2 3 |
[centos@ip-172-31-16-82 slab-nss]$ sudo pip install awscli ・・・ Successfully installed awscli-1.15.53 botocore-1.10.52 colorama-0.3.9 docutils-0.14 futures-3.2.0 jmespath-0.9.3 ordereddict-1.1 pyasn1-0.4.3 python-dateutil-2.6.1 rsa-3.4.2 s3transfer-0.1.13 simplejson-3.3.0 |
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/awscli-install-linux.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
[centos@ip-172-31-16-82 slab-nss]$ sudo yum install --enablerepo=remi --enablerepo=remi-php55 php Loaded plugins: fastestmirror, presto Setting up Install Process Loading mirror speeds from cached hostfile epel/metalink * base: ftp.iij.ad.jp * epel: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * remi: ftp.riken.jp * remi-php55: ftp.riken.jp * remi-safe: ftp.riken.jp * updates: ftp.iij.ad.jp base extras remi remi/primary_db remi-php55 remi-php55/primary_db remi-safe remi-safe/primary_db updates Resolving Dependencies --> Running transaction check ---> Package php.x86_64 0:5.3.3-49.el6 will be updated ---> Package php.x86_64 0:5.5.38-8.el6.remi will be an update --> Processing Dependency: php-common(x86-64) = 5.5.38-8.el6.remi for package: php-5.5.38-8.el6.remi.x86_64 --> Processing Dependency: php-cli(x86-64) = 5.5.38-8.el6.remi for package: php-5.5.38-8.el6.remi.x86_64 --> Running transaction check ---> Package php-cli.x86_64 0:5.3.3-49.el6 will be updated ---> Package php-cli.x86_64 0:5.5.38-8.el6.remi will be an update ---> Package php-common.x86_64 0:5.3.3-49.el6 will be updated ---> Package php-common.x86_64 0:5.5.38-8.el6.remi will be an update --> Processing Dependency: php-pecl-zip(x86-64) for package: php-common-5.5.38-8.el6.remi.x86_64 --> Processing Dependency: php-pecl-jsonc(x86-64) for package: php-common-5.5.38-8.el6.remi.x86_64 --> Running transaction check ---> Package php-pecl-jsonc.x86_64 0:1.3.10-2.el6.remi.5.5 will be installed ---> Package php-pecl-zip.x86_64 0:1.15.3-1.el6.remi.5.5 will be installed --> Processing Dependency: libzip5(x86-64) >= 1.5.1 for package: php-pecl-zip-1.15.3-1.el6.remi.5.5.x86_64 --> Processing Dependency: libzip.so.5()(64bit) for package: php-pecl-zip-1.15.3-1.el6.remi.5.5.x86_64 --> Running transaction check ---> Package libzip5.x86_64 0:1.5.1-1.el6.remi will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================= Package Arch Version ======================================================================================================================================================= Updating: php x86_64 5.5.38-8.el6.remi Installing for dependencies: libzip5 x86_64 1.5.1-1.el6.remi php-pecl-jsonc x86_64 1.3.10-2.el6.remi.5.5 php-pecl-zip x86_64 1.15.3-1.el6.remi.5.5 Updating for dependencies: php-cli x86_64 5.5.38-8.el6.remi php-common x86_64 5.5.38-8.el6.remi Transaction Summary ======================================================================================================================================================= Install 3 Package(s) Upgrade 3 Package(s) Total download size: 7.8 M Is this ok [y/N]: y Downloading Packages: Setting up and reading Presto delta metadata Processing delta metadata Package(s) data still to download: 7.8 M (1/6): libzip5-1.5.1-1.el6.remi.x86_64.rpm (2/6): php-5.5.38-8.el6.remi.x86_64.rpm (3/6): php-cli-5.5.38-8.el6.remi.x86_64.rpm (4/6): php-common-5.5.38-8.el6.remi.x86_64.rpm (5/6): php-pecl-jsonc-1.3.10-2.el6.remi.5.5.x86_64.rpm (6/6): php-pecl-zip-1.15.3-1.el6.remi.5.5.x86_64.rpm ------------------------------------------------------------------------------------------------------------------------------------------------------- Total warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi Importing GPG key 0x00F97F56: Userid : Remi Collet <RPMS@FamilleCollet.com> Package: remi-release-6.9-3.el6.remi.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi Is this ok [y/N]: y Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : libzip5-1.5.1-1.el6.remi.x86_64 Installing : php-pecl-jsonc-1.3.10-2.el6.remi.5.5.x86_64 WARNING : These php-* RPMs are not official Fedora / Red Hat build and overrides the official ones. Don't file bugs on Fedora Project nor Red Hat. Use dedicated forum at http://forum.remirepo.net/ Updating : php-common-5.5.38-8.el6.remi.x86_64 Installing : php-pecl-zip-1.15.3-1.el6.remi.5.5.x86_64 Updating : php-cli-5.5.38-8.el6.remi.x86_64 Updating : php-5.5.38-8.el6.remi.x86_64 Cleanup : php-5.3.3-49.el6.x86_64 Cleanup : php-cli-5.3.3-49.el6.x86_64 Cleanup : php-common-5.3.3-49.el6.x86_64 ========================================================================== WARNING : PHP 5.5 have reached its "End of Life" in July 2016. Even, if this package includes some security fix, backported from 5.6, The UPGRADE to a maintained version is very strongly RECOMMENDED. ========================================================================== Verifying : libzip5-1.5.1-1.el6.remi.x86_64 Verifying : php-pecl-zip-1.15.3-1.el6.remi.5.5.x86_64 Verifying : php-cli-5.5.38-8.el6.remi.x86_64 Verifying : php-pecl-jsonc-1.3.10-2.el6.remi.5.5.x86_64 Verifying : php-common-5.5.38-8.el6.remi.x86_64 Verifying : php-5.5.38-8.el6.remi.x86_64 Verifying : php-cli-5.3.3-49.el6.x86_64 Verifying : php-5.3.3-49.el6.x86_64 Verifying : php-common-5.3.3-49.el6.x86_64 Dependency Installed: libzip5.x86_64 0:1.5.1-1.el6.remi php-pecl-jsonc.x86_64 0:1.3.10-2.el6.remi.5.5 php-pecl-zip.x8 Updated: php.x86_64 0:5.5.38-8.el6.remi Dependency Updated: php-cli.x86_64 0:5.5.38-8.el6.remi php-common.x86_64 0:5.5.38-8.el6.remi Complete! |
1 2 |
[centos@ip-172-31-16-82 slab-nss]$ php publish.php PHP Fatal error: Class 'SimpleXMLElement' not found in /home/centos/aws/slab-nss/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php on line 886 |
こんなエラーが出たので、
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
[centos@ip-172-31-16-82 slab-nss]$ sudo yum install --enablerepo=remi --enablerepo=remi-php55 php-xml Loaded plugins: fastestmirror, presto Setting up Install Process Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * epel: mirrors.aliyun.com * extras: ftp.iij.ad.jp * remi: ftp.riken.jp * remi-php55: ftp.riken.jp * remi-safe: ftp.riken.jp * updates: ftp.iij.ad.jp Resolving Dependencies --> Running transaction check ---> Package php-xml.x86_64 0:5.5.38-8.el6.remi will be installed --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.24)(64bit) for package: php-xml-5.5.38-8.el6.remi.x86_64 --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.22)(64bit) for package: php-xml-5.5.38-8.el6.remi.x86_64 --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: php-xml-5.5.38-8.el6.remi.x86_64 --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.13)(64bit) for package: php-xml-5.5.38-8.el6.remi.x86_64 --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: php-xml-5.5.38-8.el6.remi.x86_64 --> Processing Dependency: libxslt.so.1()(64bit) for package: php-xml-5.5.38-8.el6.remi.x86_64 --> Processing Dependency: libexslt.so.0()(64bit) for package: php-xml-5.5.38-8.el6.remi.x86_64 --> Running transaction check ---> Package libxslt.x86_64 0:1.1.26-2.el6_3.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================= Package Arch Version ======================================================================================================================================================= Installing: php-xml x86_64 5.5.38-8.el6.remi Installing for dependencies: libxslt x86_64 1.1.26-2.el6_3.1 Transaction Summary ======================================================================================================================================================= Install 2 Package(s) Total download size: 670 k Installed size: 2.9 M Is this ok [y/N]: y Downloading Packages: Setting up and reading Presto delta metadata Processing delta metadata Package(s) data still to download: 670 k (1/2): libxslt-1.1.26-2.el6_3.1.x86_64.rpm (2/2): php-xml-5.5.38-8.el6.remi.x86_64.rpm ------------------------------------------------------------------------------------------------------------------------------------------------------- Total Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : libxslt-1.1.26-2.el6_3.1.x86_64 Installing : php-xml-5.5.38-8.el6.remi.x86_64 Verifying : libxslt-1.1.26-2.el6_3.1.x86_64 Verifying : php-xml-5.5.38-8.el6.remi.x86_64 Installed: php-xml.x86_64 0:5.5.38-8.el6.remi Dependency Installed: libxslt.x86_64 0:1.1.26-2.el6_3.1 Complete! |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[centos@ip-172-31-16-82 slab-nss]$ composer.phar update Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 3 installs, 0 updates, 0 removals - Installing symfony/event-dispatcher (v2.6.13): Downloading (100%) The following exception is caused by a lack of memory or swap, or not having swap configured Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details PHP Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer.phar/vendor/symfony/console/Application.php on line 959 Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer.phar/vendor/symfony/console/Application.php on line 959 [ErrorException] proc_open(): fork failed - Cannot allocate memory update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]... |
となったので、
1 2 3 4 5 6 7 8 |
[root@ip-172-31-16-82 slab-nss]# /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 15.1272 s, 71.0 MB/s [root@ip-172-31-16-82 slab-nss]# /sbin/mkswap /var/swap.1 Setting up swapspace version 1, size = 1048572 KiB no label, UUID=001c4bd6-1612-4241-9a0c-8fe3b27f5e08 [root@ip-172-31-16-82 slab-nss]# /sbin/swapon /var/swap.1 |
と作成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[centos@ip-172-31-16-82 slab-nss]$ composer.phar update Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 3 installs, 0 updates, 0 removals - Installing symfony/event-dispatcher (v2.6.13): Loading from cache - Installing guzzle/guzzle (v3.9.3): Downloading (100%) - Installing aws/aws-sdk-php (2.8.31): Downloading (100%) symfony/event-dispatcher suggests installing symfony/dependency-injection () symfony/event-dispatcher suggests installing symfony/http-kernel () guzzle/guzzle suggests installing guzzlehttp/guzzle (Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated.) aws/aws-sdk-php suggests installing doctrine/cache (Adds support for caching of credentials and responses) aws/aws-sdk-php suggests installing ext-apc (Allows service description opcode caching, request and response caching, and credentials caching) aws/aws-sdk-php suggests installing monolog/monolog (Adds support for logging HTTP requests and responses) aws/aws-sdk-php suggests installing symfony/yaml (Eases the ability to write manifests for creating jobs in AWS Import/Export) Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead. Writing lock file Generating autoload files |
とできた。
AWS SDKを使用しているとslabが肥大化していく現象
NSS_SDB_USE_CACHE=yesが利用できるのが、nss3.16以上とあるが、
nss-softokn-3.14.3-12.el6 という情報もあるため、確認
https://bugzilla.redhat.com/show_bug.cgi?id=1044666
http://tama1029hq.hatenablog.com/entry/2016/12/12/105353
—
Amazon Linux
1 2 3 4 5 6 7 |
[root@freeserver ec2-user]# rpm -qa | grep nss-softokn nss-softokn-3.16.2.3-14.2.38.amzn1.x86_64 nss-softokn-freebl-3.16.2.3-14.2.38.amzn1.x86_64 [root@freeserver ec2-user]# curl -V curl 7.47.1 (x86_64-redhat-linux-gnu) libcurl/7.47.1 NSS/3.21 Basic ECC zlib/1.2.8 libidn/1.18 libpsl/0.6.2 (+libicu/50.1.2) libssh2/1.4.2 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets PSL |
この場合、NSS/3.21
が有効なのだろうか。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@freeserver ec2-user]# strace -fc -e trace=access curl -s https://www.google.co.jp/ > /dev/null Process 29754 attached % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000008 0 5383 5378 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000008 5383 5378 total [root@freeserver ec2-user]# NSS_SDB_USE_CACHE=yes strace -fc -e trace=access curl -s https://www.google.co.jp/ > /dev/null Process 29780 attached % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 0.00 0.000000 0 17 14 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000000 17 14 total [root@freeserver ec2-user]# yum list nss-softokn |
→効いている。
—
さくら(CentOS release 6.6 (Final))
1 2 3 4 5 6 7 8 9 |
[nilesflow@dev ~]$ cat /etc/redhat-release CentOS release 6.6 (Final) [nilesflow@dev ~]$ rpm -qa | grep nss-softokn nss-softokn-3.14.3-18.el6_6.x86_64 nss-softokn-freebl-3.14.3-18.el6_6.x86_64 [nilesflow@dev ~]$ curl -V curl 7.46.0 (x86_64-pc-linux-gnu) libcurl/7.46.0 OpenSSL/1.0.1e zlib/1.2.3 libidn/1.18 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets |
1 2 3 4 5 6 7 8 9 10 11 |
[nilesflow@dev ~]$ strace -fc -e trace=access curl 'https://www.google.com' > /dev/null Process 3673 attached Process 3673 detached % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 12028 0 12028 0 0 84852 0 --:--:-- --:--:-- --:--:-- 87795 % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- -nan 0.000000 0 3 2 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000000 3 2 total |
→再現しない
—
CentOS6.9(Amazonマーケットプレイス)
1 2 3 4 5 6 7 8 9 |
[centos@ip-172-31-16-82 ~]$ cat /etc/redhat-release CentOS release 6.9 (Final) [centos@ip-172-31-16-82 ~]$ rpm -qa | grep nss-softokn nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64 nss-softokn-3.14.3-23.3.el6_8.x86_64 [centos@ip-172-31-16-82 ~]$ curl -V curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz |
1 2 3 4 5 6 7 8 9 10 11 12 |
[centos@ip-172-31-16-82 ~]$ strace -fc -e trace=access curl -s https://www.google.co.jp/ > /dev/null % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000072 0 1811 1808 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000072 1811 1808 total [centos@ip-172-31-16-82 ~]$ NSS_SDB_USE_CACHE=yes strace -fc -e trace=access curl -s https://www.google.co.jp/ > /dev/null % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 0.00 0.000000 0 24 21 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000000 24 21 total |
→効いている
普通にやると次のようなエラーが出てはまった
1 2 3 4 5 6 7 8 9 |
Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/pi/aws-iot/AWSIoTSpeaker/modules/speaker.py", line 64, in threadWaitPlay for event in pygame.event.get(): error: video system not initialized |
http://d.hatena.ne.jp/kadotanimitsuru/20090216/thread
あたりから辿り、
https://www.raspberrypi.org/forums/viewtopic.php?t=46096
1 2 3 4 |
import os os.environ["SDL_VIDEODRIVER"] = "dummy" pygame.init() |
で回避できた。
1 |
sudo apt-get install alsa-utils sox libsox-fmt-all |
1 2 3 4 5 |
pi@raspberrypi:~/aws-iot/AwsIoTListener $ arecord -l **** ハードウェアデバイス CAPTURE のリスト **** カード 1: Device [USB PnP Sound Device], デバイス 0: USB Audio [USB Audio] サブデバイス: 1/1 サブデバイス #0: subdevice #0 |
1 2 |
pi@raspberrypi:~/aws-iot/AwsIoTListener $ arecord -f S16_LE -r 44100 -D hw:0,0 record.wav arecord: main:788: audio open error: そのようなファイルやディレクトリはありません |
1 2 3 4 5 |
pi@raspberrypi:~/aws-iot/AwsIoTListener $ lsusb Bus 001 Device 004: ID 8086:0808 Intel Corp. Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub |
1 2 3 |
pi@raspberrypi:~/aws-iot/AwsIoTListener $ cat /proc/asound/modules 0 snd_bcm2835 1 snd_usb_audio |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
pi@raspberrypi:~/aws-iot/AwsIoTListener $ amixer -c 1 sget Mic Simple mixer control 'Mic',0 Capabilities: cvolume cvolume-joined cswitch cswitch-joined Capture channels: Mono Limits: Capture 0 - 16 Mono: Capture 0 [0%] [0.00dB] [on] pi@raspberrypi:~/aws-iot/AwsIoTListener $ amixer -c 1 sset Mic 60% Simple mixer control 'Mic',0 Capabilities: cvolume cvolume-joined cswitch cswitch-joined Capture channels: Mono Limits: Capture 0 - 16 Mono: Capture 10 [62%] [14.88dB] [on] pi@raspberrypi:~/aws-iot/AwsIoTListener $ pi@raspberrypi:~/aws-iot/AwsIoTListener $ amixer -c 1 sget Mic Simple mixer control 'Mic',0 Capabilities: cvolume cvolume-joined cswitch cswitch-joined Capture channels: Mono Limits: Capture 0 - 16 Mono: Capture 10 [62%] [14.88dB] [on] |
カード番号を合わせると録音できた。
1 2 3 |
pi@raspberrypi:~/aws-iot/AwsIoTListener $ arecord -D plughw:1,0 -d 10 -f cd test.wav 録音中 WAVE 'test.wav' : Signed 16 bit Little Endian, レート 44100 Hz, ステレオ ^Cシグナル 割り込み で中断... |
失敗する
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
pi@raspberrypi:~/aws-iot/AwsIoTListener $ sudo pip install pyaudio Collecting pyaudio Downloading https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Building wheels for collected packages: pyaudio Running setup.py bdist_wheel for pyaudio ... error Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1ahdfw/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpGn57Onpip-wheel- --python-tag cp27: running bdist_wheel running build running build_py creating build creating build/lib.linux-armv6l-2.7 copying src/pyaudio.py -> build/lib.linux-armv6l-2.7 running build_ext building '_portaudio' extension creating build/temp.linux-armv6l-2.7 creating build/temp.linux-armv6l-2.7/src arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-9xgeTe/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv6l-2.7/src/_portaudiomodule.o src/_portaudiomodule.c:29:23: fatal error: portaudio.h: そのようなファイルやディレクトリはありません #include "portaudio.h" ^ compilation terminated. error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for pyaudio Running setup.py clean for pyaudio Failed to build pyaudio Installing collected packages: pyaudio Running setup.py install for pyaudio ... error Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1ahdfw/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-BFv9vm-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib.linux-armv6l-2.7 copying src/pyaudio.py -> build/lib.linux-armv6l-2.7 running build_ext building '_portaudio' extension creating build/temp.linux-armv6l-2.7 creating build/temp.linux-armv6l-2.7/src arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-9xgeTe/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv6l-2.7/src/_portaudiomodule.o src/_portaudiomodule.c:29:23: fatal error: portaudio.h: そのようなファイルやディレクトリはありません #include "portaudio.h" ^ compilation terminated. error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1ahdfw/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-BFv9vm-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-1ahdfw/pyaudio/ |
次のコマンドで失敗
1 |
sudo pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio |
次で入れる
1 |
$ sudo apt-get install python-pyaudio |
次のように
1 2 |
$ sudo pip install pyaudio Requirement already satisfied: pyaudio in /usr/lib/python2.7/dist-packages |
マイクの音量が小さくなっている。
1 |
amixer -D hw:1 sset Mic 100% |
解説記事は色々流れているけど、実際に触ってみないと覚えないので。
async / await は Promiseと関連している。まず、時系列を整理。
async / await を理解するにあたってはまずPromiseから。
例えば次のようなHTTPリクエストの非同期処理を考える。
1 2 3 4 5 6 7 8 9 10 11 12 |
request = (options) => { const req = https.request(options, (res) => { res.on('data', (body) => { return; // ★2 }); }); req.on('error', (e) => { throw e; }); req.end(); // ★1 } |
この例では、★1まで処理が進行して関数を抜けてしまってから、★2が実行される。
node.js の イベントループモデルはそもそもがそういうものなのだけど、
やっぱり同期処理的に書いたり処理した方がいいよね、ということで可能にしたのがPromiseで、
次のように既存処理を括って書ける。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
request = (options) => { return new Promise((resolve, reject) => { const req = https.request(options, (res) => { res.on('data', (body) => { resolve(body); // ★2 }); }); req.on('error', (e) => { reject(e); // ★2 }); req.end(); // ★1 }); // ★3 } |
この場合、★1まで処理が進行した後、★2で応答を返すまで Promise が処理を返さない。
★2が実行されると、★3以降の処理が実行される、というもの。
ちなみに、上記の例で、呼び出し側は次のようになる。
1 2 3 4 5 6 7 |
request(options) .then((body) => { console.log(body); }) .catch((e) => { console.log(e); }); |
async/awaitは、上記 Promise の呼び出しを簡略化して、
かつ、処理の流れ自体を同期化する仕組み。
async の簡単な説明、
要は、既存の関数をそのまま、同期処理に変えることができる。
しかし、ポイントがあって、あくまで「その関数」内の return / throw に作用するので、上記に示したような、ライブラリのコールバックには対応できない。(と思う)
なので、async で Promise 実装を簡潔化しよう、と思っても、Promise は残らざるを得ない。(はず)
※ async function って、「非同期で処理される関数です」じゃなくて、「非同期処理を含む関数(だけどPromiseで同期的に処理できる)です」ってことですね。ちょっと混乱した。
対して、await。
なので、await で同期的に待つ、という事をしたい場合は、その関数自身が async function である必要があり、
つまりは、Promise を返すことになり、つまりは、同期的に処理されうる関数になる。
なので、await で待つことを決めた時点で、その関数は同期的な関数になり、その関数が async function になることで、その上位の関数にも、同期関数になるかどうかの選択を与える、という連鎖が続く。
これが最上位まで続くと、そのコールスタック全てが同期的に処理されることが、言語的に保証される。
というものなんだな、という理解。
Promise を待つ場合、従来の then, catch が使えるので、await を使う必要は必ずしも無いが、処理を簡潔にさせる等の理由で使うという判断ができる。
上記の呼び出し例は、await を使うと、次のように書ける。
1 |
await const body = request(options); |
エラー処理のために、try – catch も、Promise 同様に then, catch を使うこともできるが、
catch を使った方が処理が簡潔に書ける。
1 2 3 4 |
await const body = request(options) .catch((e) => { console.log(e); }); |
async function にすると、Promise が返されるので、呼び出し元では、await 等の Promise 的な処理を行う必要がある。なので、非同期処理が無いにも関わらず、async 化しておくのは無駄のように見える。
async/await モデルにおいては、async function にした時点で、呼び出し元には await を使うことになり、その関数も必然的に async function になるので、という連鎖が続くので、全てを async function にする必要が出てくる。
そうさせないためには、あえて、async function だけど同期的に処理されていることが保証されていて呼び出し元に伝搬させる必要がないから、await は用いず、Promise の処理を行って、async をつけない、ということを行う必要がある。
ということが正解なのかがよくわからない。
async/await を使った場合の、伝搬例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
// async を使った方が簡潔だけど、ライブラリ等の都合で async にできない場合は Promise実装 function funcA() { return new Promise((resolve, reject) => { const req = https.request(options, (res) => { res.on('data', (body) => { resolve(body); }); }); }); } // funcA を呼び出す場合、await が使える。その場合、async を使う必要がある。 async function funcB() { const body = await funcA(); return true; } // funcB が同期的に処理されることがわかっている場合、async しないために、await しなくてもよい。 function funcC() { funcB(); } // でも非同期処理が有りうるなら、await を使うことになるだろう async function funcD() { await funcB(); } // 最上位からコールスタック全体を同期的に処理したいなら、async を伝搬して使うことになるだろう async function main() { await funcD() } |
Node.js 8.10 ランタイムから、イベントハンドラ自体を async で記述できるようになっている。
1 2 3 4 5 |
exports.myHandler = async function(event, context) { return "some success message”; // or // throw new Error(“some error type”); } |
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/nodejs-prog-model-handler.html
なので、中の処理を同期的に書いてもいいよ、ということになっている。
async function では、await が使えるので、中で async function を定義して、コールしていくという作りにできる。
$ wget https://cli-assets.heroku.com/branches/stable/heroku-linux-amd64.tar.gz
$ tar xf heroku-linux-amd64.tar.gzmv heroku /usr/local/.