流石にそろそろPromiseとか

流石にそろそろPromiseをね。 多分下記みたいな感じで動くと思う。

azu.github.io

を読んだ。

polyfill

IE11対応はやっぱり必須です

<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>

axiosとかの生Promise

axiosを使った場合はこれで良い気がする

function asyncFunction() {
    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            resolve('Async Hello world');
        }, 16);
    })
};

asyncFunction().then(function (value) {
    console.log("p-phase1 end")
    return asyncFunction();
}).then(function (value) {
    console.log("p-phase2 end")
}).catch(function (error) {
    console.error("error");
});

jQueryを使った場合

TODO: IE11でも動くか確認する

$.ajax({
    url: 'test.php',
    data: {
        param: '200'
    }
}).then(function () {
    window.console.log("phase1 end");
    return $.ajax({
        url: 'test.php',
        data: {
            param: '200'
        }
    });
}).then(function () {
    window.console.log("phase2 end");
    return $.ajax({
        url: 'test.php',
        data: {
            param: '200'
        }
    })
}).done(function () {
    window.console.log("phase3 end");
    window.console.log("終了");
}).fail(function () {
    window.console.log("fail");
    window.console.log("終了");
})

追記

IE11でも動いた

h2o web serverでLaravelをfastcgi(php-fpmに繋げて)で動かそうとして詰んでる。誰か助けて too many internal delegations

もう、一日詰んでいる。
GitHubに質問するほど自分の設定に自信がなくて自分のブログにゲロする。

環境

Ubuntu 
h2o 2.2.4とか2.3.0-DEV@5597dbeとか
(1.3DEVから今日、アップデーとしてダメになった)
Laravel 5.6
PHP7.2

設定状況

php-fpmに繋げたいので下記の設定を入れている

file.index: [ 'index.html', 'index.htm', 'index.txt', 'index.php' ]

file.custom-handler:
  extension: .php
  fastcgi.connect:
    port: /run/php/php7.2-fpm.sock
    type: unix
  "aaaa.com:443":
     listen:
       port: 443
       ssl:
          certificate-file: /etc/letsencrypt/live/aaaa.com/fullchain.pem
          key-file: /etc/letsencrypt/live/aaaa.com/privkey.pem
          cipher-suite: "EECDH+AESGCM:AES256+EECDH:AES128+EECDH"
          minimum-version: TLSv1.2
     paths:
       "/":
          file.dir: /path/to/public
          redirect:
             url: /index.php/
             internal: YES
#             internal: NO 
             status: 307

状況

エラー:
too many internal delegations

internale:YESでindex.php/hogeが内部で動いて欲しい。
動いて欲しいです。

上記のエラーはh2o/lib/core/request.cの370行目で吐かれてるように見える

        if (req->num_delegated == req->conn->ctx->globalconf->max_delegations) {
            /* TODO log */
            h2o_send_error_502(req, "Gateway Error", "too many internal delegations", 0);

この値は設定ファイルのmax_delegationsで設定できるように見えるが

max-delegations: 10000000

とかしてもエラー状況は変わらず。

internal: YESにしたら内部的にループしちゃっている感じもするけどC言語が読めないのでわからない。
Laravelの動きも関係するのかもしれないがわからない。
.htaccessでのRewriteは関係ないはずだけれども一応入れている。
ver1.3devの頃は動いていた気がする。
ver2からなんか挙動が変わったよ、というのもあるので関係あるのかないのか。。。
don't redirect (with `/` added) in core; do it in the `file.dir` handler by kazuho · Pull Request #820 · h2o/h2o · GitHub

もうかれこれ8時間ぐらい詰まっているのでわけがわからない。
誰か助けてください。。
助けて。。

追記

わからないなりにソースに手を加えてみる。

         char buf[128];
         snprintf(buf, 128, "too many internal delegations %d", req->num_delegated);
           h2o_send_error_502(req, "Gateway Error", buf, 0);

結果

too many internal delegations 10000000

あちゃー。これはあちゃー。
なぜこんなことが助けて。。。
Github行こうかな。

追記 自己解決

コンフィグをコメントアウトしていったら
下記が原因だった

  "aaaa.com":
    listen:
      port: 80
    paths:
      "/":
        redirect: "https://aaaa.com"

  "aaaa.com:80":
    listen:
      port: 80
    paths:
      "/":
        redirect: "https://aaaa.com"

にしたら解決した。

SPFレコードの確認をするツールをforkして作った

github.com
仕事でspfレコードの正しさを確認する必要があったので
ツールを作った。
githubに似たようなことをしているプロジェクトを見つけたのでforkして作業。
・pyhont2系なのかな。python3系で動く用に変更
spfレコードのDNS LOOKUP制限 = 10回を超えているかを可視化

/etc/resolv.confがおかしくdigできないホストとかあったのでgoogleの8.8.8.8を設定した。

昼休みプログラミング

ついにC言語のプロジェクトへメインプログラマとして(C言語初心者)

C言語プロジェクト。しかもチューニング系。
やばし。マクロとかまだぜんぜんわかってない。まぁ、なんとかするでしょ。私なら
20時間ぐらいGStreamerというライブラリについて右往左往した。
Macはなんかフル機能つかえないっぽい。VMWindowsでも使えないっぽい。
結局DAW用のWin7マシンにVS2017Community入れてTeamViewer経由できちんと動いた。
再生とスクリーンショットを取れたところまで。
なんだかムダな努力を積み重ねた気がするよ。終末吹っ飛んで辛い。
どうやってC言語まなんで行こうか思案中
Cを学ぶIDEEclipseで良いですかね。。。補完効くのかしら?効かないとやだなぁ。

github.com