{"action":"created","comment":{"url":"https://api.github.com/repos/voidlinux/void-packages/pulls/comments/49148870","id":49148870,"diff_hunk":"@@ -0,0 +1,287 @@\n+# -*- coding: utf-8 -*-\n+'''\n+The service module for runit and sv service management\n+\n+HomePage: http://smarden.org/runit/\n+\n+XXX unit test on all functions\n+XXX compare output to same functions on CentOS platform (systemd)\n+XXX use decorator.memoize to speedup ?\n+'''\n+from __future__ import absolute_import\n+\n+# Import python libs\n+import os\n+import glob\n+import logging\n+\n+log = logging.getLogger(__name__)\n+\n+__func_alias__ = {\n+    'reload_': 'reload'\n+}\n+\n+# Define the module's virtual name\n+__virtualname__ = 'service'\n+\n+\n+def __virtual__():\n+    '''\n+    Only work on systems with runit as init process (PID 1)\n+    '''\n+    if __grains__['init'] == 'runit' and os.path.exists('/usr/bin/sv'):\n+        return __virtualname__\n+    return False\n+\n+\n+def start(name):\n+    '''\n+    Start the specified service\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt '*' service.start <service name>\n+    '''\n+    cmd = '/usr/bin/sv start {0}'.format(name)\n+    return not __salt__['cmd.retcode'](cmd)\n+\n+\n+def stop(name):\n+    '''\n+    Stop the specified service\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt '*' service.stop <service name>\n+    '''\n+    cmd = '/usr/bin/sv force-shutdown {0}'.format(name)\n+    return not __salt__['cmd.retcode'](cmd)\n+\n+\n+def restart(name):\n+    '''\n+    Restart the named service\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt '*' service.restart <service name>\n+    '''\n+    cmd = '/usr/bin/sv force-restart {0}'.format(name)\n+    return not __salt__['cmd.retcode'](cmd)\n+\n+\n+def reload_(name):\n+    '''\n+    Reload the named service\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt '*' service.reload <service name>\n+    '''\n+    cmd = '/usr/bin/sv force-reload {0}'.format(name)\n+    return not __salt__['cmd.retcode'](cmd)\n+\n+\n+def status(name, sig=None):\n+    '''\n+    Return the status for a service, returns a bool whether the service is\n+    running.\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt '*' service.status <service name>\n+    '''\n+    if sig:\n+        return bool(__salt__['status.pid'](sig))\n+    cmd = '/usr/bin/sv status {0}'.format(name)\n+    return not __salt__['cmd.retcode'](cmd)\n+\n+\n+def _get_svc_list(name=None, status=None):\n+    '''\n+    Return list of service <name> (or all) that has the specified service <status>\n+\n+    status: 'ENABLED' or 'DISABLED' or None (all services)\n+\n+        'DISABLED' : available service but not enabled\n+        'ENABLED'  : enabled service\n+    '''\n+\n+    # sv principles:\n+    #   - file /var/service/<name> (-> /etc/sv/<folder> ) : enabled service\n+    #   - file /etc/sv/<folder>/run : available service\n+    # Notes:\n+    #  - broken /var/service/<symlink> are silently discarted\n+    #  - compare path but return service names.\n+    #\n+    # XXX if /etc/sv/<srv1> -> /etc/sv/<srv2>, \n+    #       use <srv1> as name, discard <srv2>\n+\n+    globname = '*'\n+    if name is not None:\n+        globname = name\n+\n+    # retrieve available service(s) as /etc/sv/<srv>/run\n+    ava = set()\n+    for el in glob.glob('/etc/sv/{0}/run'.format(globname)):\n+        s = os.path.dirname(el)\n+        ava.add(s)\n+        log.trace(\"found available service: {0}\".format(s))\n+\n+    # retrieve enabled service(s) as /etc/sv/<srv>/run\n+    ena = set()\n+    for el in glob.glob('/var/service/{0}/run'.format(globname)):","path":"srcpkgs/salt/files/xbps-runit-void-support/modules/runit-sv_service.py","position":143,"original_position":143,"commit_id":"5689a19cd4ed3e4c3096bc889fec541377f4e305","original_commit_id":"5689a19cd4ed3e4c3096bc889fec541377f4e305","user":{"login":"Vaelatern","id":7906072,"avatar_url":"https://avatars.githubusercontent.com/u/7906072?v=3","gravatar_id":"","url":"https://api.github.com/users/Vaelatern","html_url":"https://github.com/Vaelatern","followers_url":"https://api.github.com/users/Vaelatern/followers","following_url":"https://api.github.com/users/Vaelatern/following{/other_user}","gists_url":"https://api.github.com/users/Vaelatern/gists{/gist_id}","starred_url":"https://api.github.com/users/Vaelatern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vaelatern/subscriptions","organizations_url":"https://api.github.com/users/Vaelatern/orgs","repos_url":"https://api.github.com/users/Vaelatern/repos","events_url":"https://api.github.com/users/Vaelatern/events{/privacy}","received_events_url":"https://api.github.com/users/Vaelatern/received_events","type":"User","site_admin":false},"body":"Thank you for clarification. In this case should have a check for `down` in the directory.","created_at":"2016-01-08T01:11:54Z","updated_at":"2016-01-08T01:11:54Z","html_url":"https://github.com/voidlinux/void-packages/pull/3326#discussion_r49148870","pull_request_url":"https://api.github.com/repos/voidlinux/void-packages/pulls/3326","_links":{"self":{"href":"https://api.github.com/repos/voidlinux/void-packages/pulls/comments/49148870"},"html":{"href":"https://github.com/voidlinux/void-packages/pull/3326#discussion_r49148870"},"pull_request":{"href":"https://api.github.com/repos/voidlinux/void-packages/pulls/3326"}}},"pull_request":{"url":"https://api.github.com/repos/voidlinux/void-packages/pulls/3326","id":55339451,"html_url":"https://github.com/voidlinux/void-packages/pull/3326","diff_url":"https://github.com/voidlinux/void-packages/pull/3326.diff","patch_url":"https://github.com/voidlinux/void-packages/pull/3326.patch","issue_url":"https://api.github.com/repos/voidlinux/void-packages/issues/3326","number":3326,"state":"open","locked":false,"title":"[DO NOT MERGE] salt: add support of XBPS (package & repo management) and runit/sv (service management)","user":{"login":"yopito","id":12870617,"avatar_url":"https://avatars.githubusercontent.com/u/12870617?v=3","gravatar_id":"","url":"https://api.github.com/users/yopito","html_url":"https://github.com/yopito","followers_url":"https://api.github.com/users/yopito/followers","following_url":"https://api.github.com/users/yopito/following{/other_user}","gists_url":"https://api.github.com/users/yopito/gists{/gist_id}","starred_url":"https://api.github.com/users/yopito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yopito/subscriptions","organizations_url":"https://api.github.com/users/yopito/orgs","repos_url":"https://api.github.com/users/yopito/repos","events_url":"https://api.github.com/users/yopito/events{/privacy}","received_events_url":"https://api.github.com/users/yopito/received_events","type":"User","site_admin":false},"body":"This is a first working version.\r\nFor details and limitations of this implementation, please see `srcpkgs/salt/files/xbps-runit-void-support/README.md` in this packaging.","created_at":"2016-01-07T13:49:40Z","updated_at":"2016-01-08T01:11:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb557ee1816526bad7fbe7c845a10e5861dee760","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/voidlinux/void-packages/pulls/3326/commits","review_comments_url":"https://api.github.com/repos/voidlinux/void-packages/pulls/3326/comments","review_comment_url":"https://api.github.com/repos/voidlinux/void-packages/pulls/comments{/number}","comments_url":"https://api.github.com/repos/voidlinux/void-packages/issues/3326/comments","statuses_url":"https://api.github.com/repos/voidlinux/void-packages/statuses/5689a19cd4ed3e4c3096bc889fec541377f4e305","head":{"label":"yopito:salt","ref":"salt","sha":"5689a19cd4ed3e4c3096bc889fec541377f4e305","user":{"login":"yopito","id":12870617,"avatar_url":"https://avatars.githubusercontent.com/u/12870617?v=3","gravatar_id":"","url":"https://api.github.com/users/yopito","html_url":"https://github.com/yopito","followers_url":"https://api.github.com/users/yopito/followers","following_url":"https://api.github.com/users/yopito/following{/other_user}","gists_url":"https://api.github.com/users/yopito/gists{/gist_id}","starred_url":"https://api.github.com/users/yopito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yopito/subscriptions","organizations_url":"https://api.github.com/users/yopito/orgs","repos_url":"https://api.github.com/users/yopito/repos","events_url":"https://api.github.com/users/yopito/events{/privacy}","received_events_url":"https://api.github.com/users/yopito/received_events","type":"User","site_admin":false},"repo":{"id":42416384,"name":"void-packages","full_name":"yopito/void-packages","owner":{"login":"yopito","id":12870617,"avatar_url":"https://avatars.githubusercontent.com/u/12870617?v=3","gravatar_id":"","url":"https://api.github.com/users/yopito","html_url":"https://github.com/yopito","followers_url":"https://api.github.com/users/yopito/followers","following_url":"https://api.github.com/users/yopito/following{/other_user}","gists_url":"https://api.github.com/users/yopito/gists{/gist_id}","starred_url":"https://api.github.com/users/yopito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yopito/subscriptions","organizations_url":"https://api.github.com/users/yopito/orgs","repos_url":"https://api.github.com/users/yopito/repos","events_url":"https://api.github.com/users/yopito/events{/privacy}","received_events_url":"https://api.github.com/users/yopito/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yopito/void-packages","description":"The XBPS source packages collection","fork":true,"url":"https://api.github.com/repos/yopito/void-packages","forks_url":"https://api.github.com/repos/yopito/void-packages/forks","keys_url":"https://api.github.com/repos/yopito/void-packages/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yopito/void-packages/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yopito/void-packages/teams","hooks_url":"https://api.github.com/repos/yopito/void-packages/hooks","issue_events_url":"https://api.github.com/repos/yopito/void-packages/issues/events{/number}","events_url":"https://api.github.com/repos/yopito/void-packages/events","assignees_url":"https://api.github.com/repos/yopito/void-packages/assignees{/user}","branches_url":"https://api.github.com/repos/yopito/void-packages/branches{/branch}","tags_url":"https://api.github.com/repos/yopito/void-packages/tags","blobs_url":"https://api.github.com/repos/yopito/void-packages/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yopito/void-packages/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yopito/void-packages/git/refs{/sha}","trees_url":"https://api.github.com/repos/yopito/void-packages/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yopito/void-packages/statuses/{sha}","languages_url":"https://api.github.com/repos/yopito/void-packages/languages","stargazers_url":"https://api.github.com/repos/yopito/void-packages/stargazers","contributors_url":"https://api.github.com/repos/yopito/void-packages/contributors","subscribers_url":"https://api.github.com/repos/yopito/void-packages/subscribers","subscription_url":"https://api.github.com/repos/yopito/void-packages/subscription","commits_url":"https://api.github.com/repos/yopito/void-packages/commits{/sha}","git_commits_url":"https://api.github.com/repos/yopito/void-packages/git/commits{/sha}","comments_url":"https://api.github.com/repos/yopito/void-packages/comments{/number}","issue_comment_url":"https://api.github.com/repos/yopito/void-packages/issues/comments{/number}","contents_url":"https://api.github.com/repos/yopito/void-packages/contents/{+path}","compare_url":"https://api.github.com/repos/yopito/void-packages/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yopito/void-packages/merges","archive_url":"https://api.github.com/repos/yopito/void-packages/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yopito/void-packages/downloads","issues_url":"https://api.github.com/repos/yopito/void-packages/issues{/number}","pulls_url":"https://api.github.com/repos/yopito/void-packages/pulls{/number}","milestones_url":"https://api.github.com/repos/yopito/void-packages/milestones{/number}","notifications_url":"https://api.github.com/repos/yopito/void-packages/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yopito/void-packages/labels{/name}","releases_url":"https://api.github.com/repos/yopito/void-packages/releases{/id}","created_at":"2015-09-13T23:08:16Z","updated_at":"2015-09-13T23:08:30Z","pushed_at":"2016-01-07T14:02:35Z","git_url":"git://github.com/yopito/void-packages.git","ssh_url":"git@github.com:yopito/void-packages.git","clone_url":"https://github.com/yopito/void-packages.git","svn_url":"https://github.com/yopito/void-packages","homepage":"http://www.voidlinux.eu","size":69359,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"voidlinux:master","ref":"master","sha":"17920b4848d115c49dc4fb76f2d082e53a06e17f","user":{"login":"voidlinux","id":1512782,"avatar_url":"https://avatars.githubusercontent.com/u/1512782?v=3","gravatar_id":"","url":"https://api.github.com/users/voidlinux","html_url":"https://github.com/voidlinux","followers_url":"https://api.github.com/users/voidlinux/followers","following_url":"https://api.github.com/users/voidlinux/following{/other_user}","gists_url":"https://api.github.com/users/voidlinux/gists{/gist_id}","starred_url":"https://api.github.com/users/voidlinux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voidlinux/subscriptions","organizations_url":"https://api.github.com/users/voidlinux/orgs","repos_url":"https://api.github.com/users/voidlinux/repos","events_url":"https://api.github.com/users/voidlinux/events{/privacy}","received_events_url":"https://api.github.com/users/voidlinux/received_events","type":"Organization","site_admin":false},"repo":{"id":2060910,"name":"void-packages","full_name":"voidlinux/void-packages","owner":{"login":"voidlinux","id":1512782,"avatar_url":"https://avatars.githubusercontent.com/u/1512782?v=3","gravatar_id":"","url":"https://api.github.com/users/voidlinux","html_url":"https://github.com/voidlinux","followers_url":"https://api.github.com/users/voidlinux/followers","following_url":"https://api.github.com/users/voidlinux/following{/other_user}","gists_url":"https://api.github.com/users/voidlinux/gists{/gist_id}","starred_url":"https://api.github.com/users/voidlinux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voidlinux/subscriptions","organizations_url":"https://api.github.com/users/voidlinux/orgs","repos_url":"https://api.github.com/users/voidlinux/repos","events_url":"https://api.github.com/users/voidlinux/events{/privacy}","received_events_url":"https://api.github.com/users/voidlinux/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/voidlinux/void-packages","description":"The XBPS source packages collection","fork":false,"url":"https://api.github.com/repos/voidlinux/void-packages","forks_url":"https://api.github.com/repos/voidlinux/void-packages/forks","keys_url":"https://api.github.com/repos/voidlinux/void-packages/keys{/key_id}","collaborators_url":"https://api.github.com/repos/voidlinux/void-packages/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/voidlinux/void-packages/teams","hooks_url":"https://api.github.com/repos/voidlinux/void-packages/hooks","issue_events_url":"https://api.github.com/repos/voidlinux/void-packages/issues/events{/number}","events_url":"https://api.github.com/repos/voidlinux/void-packages/events","assignees_url":"https://api.github.com/repos/voidlinux/void-packages/assignees{/user}","branches_url":"https://api.github.com/repos/voidlinux/void-packages/branches{/branch}","tags_url":"https://api.github.com/repos/voidlinux/void-packages/tags","blobs_url":"https://api.github.com/repos/voidlinux/void-packages/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/voidlinux/void-packages/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/voidlinux/void-packages/git/refs{/sha}","trees_url":"https://api.github.com/repos/voidlinux/void-packages/git/trees{/sha}","statuses_url":"https://api.github.com/repos/voidlinux/void-packages/statuses/{sha}","languages_url":"https://api.github.com/repos/voidlinux/void-packages/languages","stargazers_url":"https://api.github.com/repos/voidlinux/void-packages/stargazers","contributors_url":"https://api.github.com/repos/voidlinux/void-packages/contributors","subscribers_url":"https://api.github.com/repos/voidlinux/void-packages/subscribers","subscription_url":"https://api.github.com/repos/voidlinux/void-packages/subscription","commits_url":"https://api.github.com/repos/voidlinux/void-packages/commits{/sha}","git_commits_url":"https://api.github.com/repos/voidlinux/void-packages/git/commits{/sha}","comments_url":"https://api.github.com/repos/voidlinux/void-packages/comments{/number}","issue_comment_url":"https://api.github.com/repos/voidlinux/void-packages/issues/comments{/number}","contents_url":"https://api.github.com/repos/voidlinux/void-packages/contents/{+path}","compare_url":"https://api.github.com/repos/voidlinux/void-packages/compare/{base}...{head}","merges_url":"https://api.github.com/repos/voidlinux/void-packages/merges","archive_url":"https://api.github.com/repos/voidlinux/void-packages/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/voidlinux/void-packages/downloads","issues_url":"https://api.github.com/repos/voidlinux/void-packages/issues{/number}","pulls_url":"https://api.github.com/repos/voidlinux/void-packages/pulls{/number}","milestones_url":"https://api.github.com/repos/voidlinux/void-packages/milestones{/number}","notifications_url":"https://api.github.com/repos/voidlinux/void-packages/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/voidlinux/void-packages/labels{/name}","releases_url":"https://api.github.com/repos/voidlinux/void-packages/releases{/id}","created_at":"2011-07-17T07:26:35Z","updated_at":"2016-01-07T05:16:11Z","pushed_at":"2016-01-08T00:28:03Z","git_url":"git://github.com/voidlinux/void-packages.git","ssh_url":"git@github.com:voidlinux/void-packages.git","clone_url":"https://github.com/voidlinux/void-packages.git","svn_url":"https://github.com/voidlinux/void-packages","homepage":"http://www.voidlinux.eu","size":76824,"stargazers_count":139,"watchers_count":139,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":172,"mirror_url":null,"open_issues_count":229,"forks":172,"open_issues":229,"watchers":139,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/voidlinux/void-packages/pulls/3326"},"html":{"href":"https://github.com/voidlinux/void-packages/pull/3326"},"issue":{"href":"https://api.github.com/repos/voidlinux/void-packages/issues/3326"},"comments":{"href":"https://api.github.com/repos/voidlinux/void-packages/issues/3326/comments"},"review_comments":{"href":"https://api.github.com/repos/voidlinux/void-packages/pulls/3326/comments"},"review_comment":{"href":"https://api.github.com/repos/voidlinux/void-packages/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/voidlinux/void-packages/pulls/3326/commits"},"statuses":{"href":"https://api.github.com/repos/voidlinux/void-packages/statuses/5689a19cd4ed3e4c3096bc889fec541377f4e305"}}}}