pm2 log timestamp
ecosystem.config.js log_date_format: 'YYYY-MM-DD HH:mm:ss',
https://pm2.keymetrics.io/docs/usage/log-management/#ecosystem
pm2-logrotate
PM2のモジュールをインストールする場合、実行ユーザーに注意が必要です。
become: trueのみ指定した場合、rootのみにモジュールがインストールされてしまいます。
become_user: xxxxxで正しいユーザーを指定しましょう。- name: Install pm2 community.general.npm: name: pm2 global: true - name: Install pm2 logrotate shell: "pm2 install pm2-logrotate" become: false ...
https://docs.ansible.com/ansible/2.9_ja/user_guide/become.html
ansible.cfg [defaults] allow_world_readable_tmpfiles = True
デフォルト
$ pm2 get pm2-logrotate Module: pm2-logrotate $ pm2 set pm2-logrotate:max_size 10M $ pm2 set pm2-logrotate:retain 30 $ pm2 set pm2-logrotate:compress false $ pm2 set pm2-logrotate:dateFormat YYYY-MM-DD_HH-mm-ss $ pm2 set pm2-logrotate:workerInterval 30 $ pm2 set pm2-logrotate:rotateInterval 0 0 * * * $ pm2 set pm2-logrotate:rotateModule true Modules configuration. Copy/Paste line to edit values.
- name: Install pm2-logrotate
shell: >
pm2 install pm2-logrotate &&
pm2 set pm2-logrotate:max_size 100M
args:
creates: /home/ec2-user/.pm2/modules/pm2-logrotate
become: false