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

218473ff7abad0fcd72865da2b23bb5b?s=47 memory
April 24, 2019

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

218473ff7abad0fcd72865da2b23bb5b?s=128

memory

April 24, 2019
Tweet

Transcript

  1. ϋϜελʔΛ؂ࢹ͢ΔγεςϜΛ Raspberry Pi ͱ PHP ͷ Swoole Ͱ࡞ͬͨ࿩ 2019/04/24 PHPษڧձ@౦ژ

    Ί΋Γʙ
  2. ͩΕʁ

  3. Ί΋Γʙ (@m3m0r7) גࣜձࣾ GameWith Ͱ αʔόʔαΠυ݉ϑϩϯτΤϯυΤϯδχΞ ͱͯ͠ಇ͍ͯ·͢ɻ ϐʔΤΠνϐʔνϣοτσΩϧ 2019 ೥ͷ

    5 ݄຤ʹ΍Ί·͢ɻస৬׆ಈதͰ͢ɻ
  4. ͏ͪͷϋϜελʔͷ͝঺հ

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

    ݏ͍ͳ৯΂෺ɿསͷ͔͡Γ໦ झຯɿڅਫثͷϊζϧΛΨδΨδ͢Δ͜ͱɻ૸ΔΑΓ޷͖Έ͍ͨͰ͢
  6. Έͳ͞ΜɺSwoole Λ࢖ͬͨ͜ͱ͸͋Γ·͔͢ʁ

  7. ͦͯ͠ɺRaspberry Pi Λ࢖ͬͨ͜ͱ͸͋Γ·͔͢ʁ

  8. None
  9. ϊʔϚϧΧϝϥϞδϡʔϧ ໷ؒ༻ΧϝϥϞδϡʔϧ

  10. ͏ͪͷ Raspberry Pi Ͱ͢

  11. None
  12. ͏ͪͷϋϜελʔઐ༻ͷϥοΫͰ͢

  13. ͜ͷ੺࿮͕ࠓճͷ Raspberry Pi Λ ͓͍ͯΔͱ͜ΖʹͳΓ·͢

  14. ٕज़ελοΫ

  15. - Raspbian (Raspberry Pi) - PHP 7.3 - Swoole v4

    - Python 3 - React.js (+ Gulp) ओʹ͜ͷ 5 ͭ
  16. අ༻͸͍͘Βͩͬͨͷ͔ʁ

  17. - 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 ԁ
  18. ׂͱ͍͍஋ஈ͠·͢

  19. ϨΠςϯγ͸ʁ

  20. ମײ 0.5 ඵ͘Β͍

  21. αʔόʔͷߏ੒

  22. ࣗ୐ LAN VPS (ConoHa) PiCamera Ϟδϡʔϧ 4 byte ͷunsigned long

    ͳαΠζσʔλ + picamera.start_recording (mjpeg) ϊʔϚϧΧϝϥ ͔Β TCP Ͱૹ৴ φΠτΧϝϥ͔Β TCP Ͱૹ৴
  23. ࣗ୐ LAN ଆ͸Ͳ͏ͳ͍ͬͯΔͷ͔ʁ

  24. - ͦ΋ͦ΋ࣗ୐ͷωοτϫʔΫͷϙʔτ͸։͚ͨ͘ͳ͔ͬͨ - தܧαʔόʔ͓͚͹ສࣄղܾʂ͘͞Βͷ VPS ͷ౦ژϦʔδϣϯ͕ۭ͍ͯ ͳ͔ͬͨͷͰɺࠓճ͸࿩୊෸ಅͷ ConoHa ΛνϣΠε -

    ϧʔλʔΛ৽ௐͯ͠࠷ߴͷ؀ڥʹͨ͠ - Python3 ͷ picamera Λ࢖ͬͯແݶʹ VPS (ConoHa) ʹૹΓ͚͍ͭͯ·͢
  25. None
  26. VPS ଆ͸Ͳ͏ͳ͍ͬͯΔͷ͔ʁ

  27. - PHP ͷ Swoole ͷ Coroutine Λ࢖ͬͯ Raspberry Pi ͔Βͷσʔλͷड৴

    ༻αʔόʔ, ConoHa ΁σʔλΛૹΔͨΊͷૹ৴༻αʔόʔΛ༻ҙ - ͨͬͨ͜Ε͚ͩʂ Simple is best.
  28. ※ Ұ෦ͷίʔυ

  29. ࣮ࡍͷϓϩμΫτͷը໘

  30. None
  31. ετϦʔϛϯάͷςετ

  32. Ͳ͏΍͔ͬͨʁ

  33. ΧϝϥͷԼͰखΛৼΓͭͭϐʔεΛ͢Δ

  34. None
  35. - mjpeg ͸ Motion JPEG ͷུɻ - H.264΋ݕ౼ͨ͠ͷͰ͕͢ɺ ffmpeg Λ௨͢ͱϨΠςϯγ͕

    5 ඵ͘Β͍૿͑Δ໰୊ ͕͋Γ, mjpeg ΛνϣΠε - MIME type ͸ multipart/x-mixed-replace Ͱৗ࣌ίωΫγϣϯΛషΔ - (ͳͷͰɺϒϥ΢βͷλϒ͸ϩʔσΟϯάதͷ··) - ϨΠςϯγ͸ ମײ 0.5 ඵ͘Β͍ɻͦ͜Β΁Μͷ΋ͷΑΓૣ͍ - ΊͬͪΌ͵Δ͵Δʹಈ͘
  36. Swoole Λ࢖ͬͯΈͯͷײ૝

  37. - PHP Ͱඇಉظॲཧ࢖͑Δͷਆʂ - Ϗϧυ࣌ʹ —enable-maintainer-zts Λ͠ͳ͍͍ͯ͘ͷͰɺಋೖͷϋʔυ ϧ͕௿͍ ( phpize

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

  39. ೋ೔ޙʹεΫϦϓτ͕མͪΔ

  40. ϩάऔͬͯͳ͍ͷͰམͪͨ ݪҼ͕Θ͔Βͳ͍ʗ(^o^)ʘ

  41. Ҏ্Ͱ͢

  42. THANK YOU FOR YOUR LISTENING !!