{"id":13709652,"url":"https://github.com/pandolia/easy-service","last_synced_at":"2025-04-05T07:04:19.719Z","repository":{"id":40336204,"uuid":"220636493","full_name":"pandolia/easy-service","owner":"pandolia","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-03T06:10:29.000Z","size":573,"stargazers_count":578,"open_issues_count":3,"forks_count":69,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-29T06:04:57.660Z","etag":null,"topics":["devops","windows-server","windows-service"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pandolia.png","metadata":{"files":{"readme":"readme.eng.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-11-09T12:06:23.000Z","updated_at":"2025-03-24T02:37:52.000Z","dependencies_parsed_at":"2023-02-17T17:30:52.764Z","dependency_job_id":null,"html_url":"https://github.com/pandolia/easy-service","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandolia%2Feasy-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandolia%2Feasy-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandolia%2Feasy-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandolia%2Feasy-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pandolia","download_url":"https://codeload.github.com/pandolia/easy-service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299831,"owners_count":20916190,"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":["devops","windows-server","windows-service"],"created_at":"2024-08-02T23:00:43.189Z","updated_at":"2025-04-05T07:04:19.701Z","avatar_url":"https://github.com/pandolia.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"[中文](https://github.com/pandolia/easy-service) | English\n\n### Introduction\n\nIf your Windows program needs to run permanently in the background, and you want it to be started automatically after system booting, then you need to register it as a system service.\n\nUnfortunately, making a program that can be registered as a system service is not an easy task. First, the propgram must be an executable binary, so you can't write it with script language like Python or virtual machine language like Java. Second, you must write it in accordance with the format of Windows Service Program, which is complecated. Refer to [MS official document](https://code.msdn.microsoft.com/windowsapps/CppWindowsService-cacf4948) to see how to make a Windows Service Program.\n\n[EasyService](https://github.com/pandolia/easy-service) is a small tool which can register normal program as a system service. It's only 37KB. You can write your program in normal way with whatever language you like, and register it as a system servie, then it will be started automatically after system booting, runs permanently in the background, and keeps runnning even after you logout the system.\n\nIf you need to deploy website server, api server or other server that runs permanently in the background in Windows, EasyService will be a very usefull tool.\n\n### Setup\n\nDownload [the source and binary of EasyService](https://github.com/pandolia/easy-service/archive/master.zip), extract it. Then right click ***bin/register-this-path.bat*** , run with Administrator to add the path of ***bin*** directory to system path. Or add it manual.\n\nReopen My Computer, open a terminal somewhere, run command *** svc -v *** to check whether the installation is successful.\n\n### Usage\n\n(1) Write and test your program. EasyService has only one mandatory requirement and a recommendation to your program:\n\n```\nmandatory requirement: the program runs permanently\n\nrecommendation: the program exits in 5 seconds when receives data \"exit\" in its stdin\n```\n\nTypical programs are: [index.js](https://github.com/pandolia/easy-service/blob/master/samples/nodejs-version/worker/index.js) (nodejs version), [main.py](https://github.com/pandolia/easy-service/blob/master/samples/python-version/worker/main.py) (Python version), and [SampleWorker.cs](https://github.com/pandolia/easy-service/blob/master/src/SampleWorker.cs)。\n\n(2) Open a terminal with administrator, run ***svc create hello-svc** to create a template project directory hello-svc.\n\n(3) Open **hello-svc/svc.conf** , edit configurations:\n\n```conf\n# service's name, DO NOT conflict with existed services\nServiceName: hello-svc\n\n# program and command line arguments\nWorker: sample-worker.exe\n\n# working directory where you want to run the program, make sure this diretory exists\nWorkingDir: worker\n\n# output of the program will be written to this directory, make sure this diretory exists\nOutFileDir: outfiles\n\n# output encoding of the program, leave empty if you are not sure\nWorkerEncoding:\n```\n\n(4) Cd to hello-svc:\n\na. run ***svc check*** to check configurations\n\nb. run ***svc test-worker*** to test your program (the Worker)\n\nIf everything are fine:\n\nc. run ***svc install*** to register and start a system service. Now your program is running in the background.\n\nd. run ***svc stop|start|restart|remove*** to stop, start, restart and remove the service.\n\n### Register multiple services\n\nTo register multiple services, just run ***svc create your-project-name*** to create multiple template project directories, edit configurations, and run **svc check|test-worker|install|...** .\n\n### Internal Implementation\n\nActually, EasyService registers himself (**svc.exe**) as a system service. When this service starts, he reads configurations in **svc.conf** and creates a child process to run the program (the Worker), then monitors the child process and re-creates one if it stops running. When this service stops (or its memory exceeds a specific value), he writes data \"exit\" to the stdin of the child process and wait for it to exit, and terminates the child process if waitting time exceeds 5 seconds.\n\nSource code of EasyService are in [src](https://github.com/pandolia/easy-service/tree/master/src) 。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandolia%2Feasy-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpandolia%2Feasy-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandolia%2Feasy-service/lists"}