{"id":13398313,"url":"https://github.com/walkr/oi","last_synced_at":"2025-04-08T03:19:29.494Z","repository":{"id":32070597,"uuid":"35642474","full_name":"walkr/oi","owner":"walkr","description":"python library for writing long running processes with a cli interface","archived":false,"fork":false,"pushed_at":"2016-03-11T23:25:44.000Z","size":43,"stargazers_count":234,"open_issues_count":0,"forks_count":10,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-08-22T08:54:33.510Z","etag":null,"topics":["nanomsg","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/walkr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-14T23:34:09.000Z","updated_at":"2024-04-25T19:06:24.000Z","dependencies_parsed_at":"2022-09-18T12:30:51.764Z","dependency_job_id":null,"html_url":"https://github.com/walkr/oi","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkr%2Foi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkr%2Foi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkr%2Foi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkr%2Foi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walkr","download_url":"https://codeload.github.com/walkr/oi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767239,"owners_count":20992548,"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":["nanomsg","python"],"created_at":"2024-07-30T19:00:22.518Z","updated_at":"2025-04-08T03:19:29.471Z","avatar_url":"https://github.com/walkr.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"oi\n==\npython library for writing long running processes with a cli interface\n\n[![Build Status](https://travis-ci.org/walkr/oi.svg?branch=master)](https://travis-ci.org/walkr/oi)\n\n![oi image](http://i.imgur.com/iH08GNq.png)\n\n\n### Install\n\nNote: You need [nanomsg](https://github.com/nanomsg/nanomsg) installed on your system:\n\n```shell\n$ git clone git@github.com:nanomsg/nanomsg.git\n$ cd nanomsg\n$ ./configure\n$ make\n$ make check\n$ sudo make install\n```\n\nThen install oi\n\n```shell\n$ pip install oi\n```\n\n### Usage\n\n\n####1. Write your long running program\n\n```python\n# programd.py\n\nimport oi\n\nprogram = oi.Program('my program', 'ipc:///tmp/program.sock')\nprogram.add_command('ping', lambda: 'pong')\nprogram.add_command('state', lambda: program.state)\nprogram.run()  # program will run forever\n```\n\n####2. Add a ctl interface\n\n```python\n# programctl.py\n\nimport oi\n\nctl = oi.CtlProgram('ctl program', address='ipc:///tmp/program.sock')\nctl.run()\n```\n\n\n####3. Run program, then connect to it via ctl\n```shell\n# Run process\n$ python programd\n\n# OR with a configuration file\n$ python programd --config /etc/program.conf\n\n$ python programctl  # enter ctl loop\nprogramctl \u003e ping\npong\n\n# OR ping end exit\n$ python programctl ping\n```\n\n#### Quickly get started with a new project\n\n```shell\n$ mkdir xprogram\n$ cd xprogram\n\n$ oi init\n$ make install\n\n# Start your program\n$ xprogramd\n\n# Start ctl program\n$ xprogramctl\nctl \u003e ping\npong\n\n# Upload to pypi (Edit setup.py before distributing)\n$ make distribute\n```\n\n### Now the interesting bit. Are you ready?\nRun your program on one computer, then control it from another with a single line change (actually two).\n\nJust change the address `ipc:///tmp/program.sock` to a tcp address, such as `tcp://192.168.1.100:5000` in both your `programd.py` and `programctl.py`. That's it! (:\n\n#### TODO\n\n- [ ] Add more testing\n\n#### License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkr%2Foi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalkr%2Foi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkr%2Foi/lists"}