Bài đăng

Cấu hình Reformat Code trong PhpStorm

Hình ảnh
Hôm qua gặp quả lỗi PhpStorm do cấu hình sai Reformat, sau 1 hồi tìm kiếm thì ra thông tin sau, nếu lỗi có thể thử fix Ấn phím tắt Option + Shift + Command + L, 1 popup sẽ hiện ra như sau PhpStorm Reformat File Dialog Cấu hình popup trên như sau Scope - Only changes uncommitted to VCS : Nếu được chọn, thì việc reformat code sẽ chỉ áp dụng cho mã đã được thay đổi cục bộ nhưng chưa được đưa vào kho lưu trữ. Tùy chọn này chỉ khả dụng cho các tệp được kiểm soát phiên bản. - Selected text : Nếu chọn scope này, PhpStorm sẽ chỉ format đoạn code được bôi đen - Whole file : Chọn options này để định dạng lại toàn bộ mã nguồn trong tệp hiện tại -> Nên chọn options này Options - Code cleanup : Chọn tùy chọn này để chạy kiểm tra dọn dẹp mã. PhpStorm tìm và tự động sửa các đoạn mã có khả năng gây ra sự cố -> nên bỏ để tránh tốn performance. Nên sử dụng các trình eslint và check để xử lý và kiểm soát tốt hơn - Do not keep line breaks : Định dạng lại ngắt dòng theo cài đặt kiểu mã. Tùy chọn này

Bash Script: Cảnh báo dung lượng ổ đĩa trên server về Telegram BOT

Hình ảnh
Trong cuộc sống nhiều khi server nó đầy bất ngờ. Script sau sẽ giúp monitoring và cảnh báo về telegram của system admin để lắp thêm storage trước khi service chết không kịp ngáp

Bash Script: Xoá bỏ các thư mục cũ sau khi releases phiên bản mới

Hình ảnh
Đối với việc thực hiện CI/CD, kịch bản thường thấy sẽ là Tạo 1 thư mục mới theo cấu trúc nhất định Code sau khi được build và test, sẽ được đồng bộ vào thư mục mới Tạo symbolic linking folder production tới thư mục mới Triển khai test trên Production Giữ lại thư mục cũ ít nhất sau 1 khoảng thời gian để rollback khi cần Đến đây có 1 vấn đề nảy sinh. Làm sao để định kỳ xoá các folder cũ khi deploy. Vậy thì script dưới đây là lời giải cho bài toán trên

Journalctl: How to Read and Edit Systemd Logs

Hình ảnh
  Introduction Systemd logs all  Linux  messages from the  kernel  and system processes. The journalctl command enables viewing and editing the systemd logs, making it a powerful tool for service and process debugging. This guide shows how to read, control, and maintain systemd logs using journalctl through examples. Prerequisites Access to the command line/terminal window. A text editor (such as  nano ) to edit the config file. A user with sudo privileges (see how to  add a user to sudoers ). What Is Systemd? Systemd is a Linux service and system manager. While users do not invoke systemd directly, the manager contains many tools and daemons to run individually for various system processes. One of the most powerful systemd functionalities is the logging features. Systemd provides a centralized solution for logging all  kernel  and user processes through logs known as  journals . The  journald  daemon collects all the messages the system outputs and then creates journals, regardless of