http://tansa.info/blog/2016/10/28/post-2974/
を参考にしてみたらどうでしょうか?