{"id":21894654,"url":"https://github.com/yamtaldev/watchdog","last_synced_at":"2025-03-22T04:20:58.580Z","repository":{"id":193037462,"uuid":"687630776","full_name":"YamtalDev/WatchDog","owner":"YamtalDev","description":"Watchdog is a library that provides functionality to monitor a code block within a process and automatically restart it if terminated.","archived":false,"fork":false,"pushed_at":"2023-09-06T10:11:24.000Z","size":22,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T05:44:05.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","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/YamtalDev.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}},"created_at":"2023-09-05T17:11:27.000Z","updated_at":"2024-12-15T12:35:33.000Z","dependencies_parsed_at":"2023-09-06T13:39:22.237Z","dependency_job_id":null,"html_url":"https://github.com/YamtalDev/WatchDog","commit_stats":null,"previous_names":["yamtaldev/watchdog"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YamtalDev%2FWatchDog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YamtalDev%2FWatchDog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YamtalDev%2FWatchDog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YamtalDev%2FWatchDog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YamtalDev","download_url":"https://codeload.github.com/YamtalDev/WatchDog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244904212,"owners_count":20529388,"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":"2024-11-28T13:27:12.499Z","updated_at":"2025-03-22T04:20:58.557Z","avatar_url":"https://github.com/YamtalDev.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Watchdog\n\nWatchdog is a library that provides functionality to monitor a code block \nwithin a process and automatically restart it if terminated.\n\n## About\n\nThe Watchdog module is designed to monitor a specific code block within a process. It continuously checks whether the process is still running. If the process terminates, the Watchdog library automatically restarts it. This ensures the uninterrupted execution of critical code blocks.\n\n* Key features of the Watchdog library:\n    - Monitors a code block within a process\n    - Automatically restarts the process if it terminates\n    - Provides functions to initiate and clean up the monitoring process\n\n## Prerequisites\n\nBefore using the Watchdog library, ensure that you have the following prerequisites installed:\n\n   - C compiler (e.g., GCC)\n   - Make utility (optional, for using the provided Makefile)\n\n## Getting Started\n\n### Installation\n\nTo install the Watchdog library, follow these steps:\n\n   1. Copy the dist folder to any place you like.\n   2. Navigate to the folder where `dist` folder is and open a `C` file to start coding.\n\n### Manual Compilation\n\nThe Watchdog library can be manually compiled using the following command:\n\ngcc -Idist \u003ccompilation_flags\u003e-L/dist -Wl,-rpath=/dist \u003cyour_file.c\u003e dist/libwatchdog.so\n\n### Using Makefile Compilation\n\n   1. Copy the `makefile` from the `dist` folder to the parent folder where your \n      `C` file is\n   2. Open the `makefile` and change the name of the `TARGET` and `SR`C` files to your \n      `C` file and desired executable name.\n\n   3. Now you can type in the terminal `make` || `make run` || `make clean` || `make debug`\n\n### Explanation of flags and shared library in the project:\n\n- `-Idist` specifies the include directory where the header files are located.\n- `-L/dist` specifies the library directory where the shared library is located.\n- `-Wl,-rpath=/dist` adds the runtime library path for the shared library.\n- `dist/libwatchdog.so` is the path to the shared library file.\n\n### Usage\n\nTo use the Watchdog library in your code, follow these steps:\n\n   1. Include the `watch_dog.h` header file in your source code.\n   2. Call the `WDWatch` function to start monitoring the code block.\n   3. Pass the time interval and command-line arguments to the `WDWatch` function.\n   4. Use the monitored code block within your process.\n   5. When you no longer need monitoring, call the `WDUnWatch` function to clean \n      up the resources.\n\n\n### Limitations\n\n* The smallest interval is 2 seconds. If 1 second is provided the `WDWatch` will \nreturn Error.\n\n### Example usage:\n\n```c\n#include \"watch_dog.h\"\n\nint main(int argc, char *argv[])\n{\n    /* Start monitoring the code block */\n    wd_status_t status = WDWatch(10, argv);\n\n    if(status != WD_SUCCESS)\n    {\n        /* Handle the error */\n    }\n\n    /* Your code goes here */\n\n    /* Clean up and stop monitoring */\n    status = WDUnWatch();\n\n    return (0);\n}\n\n```\n### Contact\n\nFor any questions about the project:\n\n# Name: Tal Aharon\n# Email: anatolik241094@gmail.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamtaldev%2Fwatchdog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyamtaldev%2Fwatchdog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamtaldev%2Fwatchdog/lists"}