Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ハムスターを監視するシステムを Raspberry Pi と PHP の Swoole で作...

memory
April 24, 2019

ハムスターを監視するシステムを Raspberry Pi と PHP の Swoole で作った話.pdf

memory

April 24, 2019
Tweet

More Decks by memory

Other Decks in Programming

Transcript

  1. Lily (ϦϦΟ) ੑผɿঁͷࢠ ஀ੜ೔ɿ2018 ೥ 11 ݄ ޷͖ͳ৯΂෺ɿ Ϗεέοτ, Ϧϯΰͷ͔͡Γ໦

    ݏ͍ͳ৯΂෺ɿསͷ͔͡Γ໦ झຯɿڅਫثͷϊζϧΛΨδΨδ͢Δ͜ͱɻ૸ΔΑΓ޷͖Έ͍ͨͰ͢
  2. - Raspbian (Raspberry Pi) - PHP 7.3 - Swoole v4

    - Python 3 - React.js (+ Gulp) ओʹ͜ͷ 5 ͭ
  3. - Raspberry Pi 3 Model B * 2 ≒ 5,200

    * 2 ≒ 10,000 ԁ - ΧϝϥϞδϡʔϧ * 2 ≒ 5,000 * 2 ≒ 10,000 ԁ - VPS (ࠓճ͸ ConoHa) ≒ 2,500/m ԁ - ϧʔλʔ ≒ 15,000 ԁ Πχγϟϧίετ ≒ 37,500 ԁ ϥϯχϯάίετ ≒ 2,500 ԁ
  4. ࣗ୐ LAN VPS (ConoHa) PiCamera Ϟδϡʔϧ 4 byte ͷunsigned long

    ͳαΠζσʔλ + picamera.start_recording (mjpeg) ϊʔϚϧΧϝϥ ͔Β TCP Ͱૹ৴ φΠτΧϝϥ͔Β TCP Ͱૹ৴
  5. - PHP ͷ Swoole ͷ Coroutine Λ࢖ͬͯ Raspberry Pi ͔Βͷσʔλͷड৴

    ༻αʔόʔ, ConoHa ΁σʔλΛૹΔͨΊͷૹ৴༻αʔόʔΛ༻ҙ - ͨͬͨ͜Ε͚ͩʂ Simple is best.
  6. - mjpeg ͸ Motion JPEG ͷུɻ - H.264΋ݕ౼ͨ͠ͷͰ͕͢ɺ ffmpeg Λ௨͢ͱϨΠςϯγ͕

    5 ඵ͘Β͍૿͑Δ໰୊ ͕͋Γ, mjpeg ΛνϣΠε - MIME type ͸ multipart/x-mixed-replace Ͱৗ࣌ίωΫγϣϯΛషΔ - (ͳͷͰɺϒϥ΢βͷλϒ͸ϩʔσΟϯάதͷ··) - ϨΠςϯγ͸ ମײ 0.5 ඵ͘Β͍ɻͦ͜Β΁Μͷ΋ͷΑΓૣ͍ - ΊͬͪΌ͵Δ͵Δʹಈ͘
  7. - PHP Ͱඇಉظॲཧ࢖͑Δͷਆʂ - Ϗϧυ࣌ʹ —enable-maintainer-zts Λ͠ͳ͍͍ͯ͘ͷͰɺಋೖͷϋʔυ ϧ͕௿͍ ( phpize

    ͚ͩͰ͍͚Δ ) - Atomic ͕ͤΊͯ serializable ͳ΋ͷ΋࢖͑ΔΑ͏ʹͳΔͱͳ͓خ͍͠ - ݱঢ়Ͱ͖ͳ͍ͷͰɺ Channel Ͱແཧ΍Γ Coroutine ؒͷσʔλͷड͚౉ ͠Λ͍ͯ͠·͢ɻ