{"id":26897299,"url":"https://github.com/atomiechen/handy-backend","last_synced_at":"2025-04-01T04:42:08.431Z","repository":{"id":243919043,"uuid":"813665651","full_name":"atomiechen/handy-backend","owner":"atomiechen","description":"A template with handy scripts to test and run programs as a daemon in the background, with logs and log rotation built-in.","archived":false,"fork":false,"pushed_at":"2025-03-05T16:37:58.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T02:02:32.897Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomiechen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-11T14:05:39.000Z","updated_at":"2025-03-05T16:38:01.000Z","dependencies_parsed_at":"2024-08-19T06:49:22.032Z","dependency_job_id":"1f864303-731d-453f-b63b-6f8b53f3fd9f","html_url":"https://github.com/atomiechen/handy-backend","commit_stats":null,"previous_names":["atomiechen/handy-backend"],"tags_count":2,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Fhandy-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Fhandy-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Fhandy-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Fhandy-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomiechen","download_url":"https://codeload.github.com/atomiechen/handy-backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246586074,"owners_count":20801026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-01T04:42:07.843Z","updated_at":"2025-04-01T04:42:08.426Z","avatar_url":"https://github.com/atomiechen.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Handy Backend\n\nA template with handy scripts to test and run programs as a daemon in the background, with `stdout` \u0026 `stderr` logs and log rotation built-in. The target program needs zero modification.\n\nRequires Python 3.6+ for log rotation.\n\n## Setup\n\n\u003e [!NOTE] \n\u003e\n\u003e All relative paths are relative to the location of the scripts.\n\n1. Use this template to create a new repository; or copy the scripts to your existing project (any location is fine, but do place them together).\n2. Open `start.sh` and modify `CMD` to set the command to run. Add setup commands (change directory, activate virtual environment, etc.) if needed.\n3. (Optional) Modify `startd.sh` to change the logging and rotation settings.\n    ```bash\n    # log directory\n    LOG_DIR=logs\n    # ---\n    # log file (will be rotated)\n    LOG_PATH=$LOG_DIR/server.log\n    # max log size in MB\n    MAX_LOG_SIZE=5\n    # ---\n    # log file of log rotation script (will be rotated)\n    ROTATE_FILE=$LOG_DIR/rotate.log\n    # max log size for rotation output in MB\n    MAX_ROTATION_LOG_SIZE=5\n    # ---\n    # python executable used to run log rotation script\n    PYTHON_CMD=python3\n    # current directory\n    CURRENT_DIR=$(dirname ${BASH_SOURCE[0]})\n    # log rotation script\n    LOG_ROTATION_PY=$CURRENT_DIR/rotatelog.py\n    # start script\n    START_SCRIPT=$CURRENT_DIR/start.sh\n    ```\n\n## Usage\n\n`./start.sh`: Run the command in the terminal.\n\n`./startd.sh`: Run the command as a daemon process in the background (return if already running), and also start log rotation using `rotatelog.py`. This script is dependent on `start.sh` and `rotatelog.py`.\n\n- both processes are run in the background with their PIDs stored in `.vars/server.pid` and `.vars/rotate.pid`, and they communicate using a fifo file `.vars/.fifo`. **Do NOT manually modify or delete these files.**\n- server logs are stored in `logs/server.log` and rotated every 5MB (can be changed in `startd.sh`)\n- rotation logs are stored in `logs/rotate.log` and rotated every 5MB (can be changed in `startd.sh`)\n\n`./statusd.sh`: Check the status of the command and the log rotation process running in the background.\n\n`./stopd.sh`: Stop the command and the log rotation process running in the background.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomiechen%2Fhandy-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomiechen%2Fhandy-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomiechen%2Fhandy-backend/lists"}