{"action":"created","comment":{"url":"https://api.github.com/repos/selendroid/selendroid/pulls/comments/22644485","id":22644485,"diff_hunk":"@@ -68,11 +66,41 @@ protected SelendroidStandaloneDriver initializeSelendroidServer() throws Android\n   public void start() {\n     webServer.start();\n     if (config.isGrid()) {\n-      try {\n-        new SelfRegisteringRemote(config, driver).performRegistration();\n-      } catch (Exception e) {\n-        log.log(Level.SEVERE, \"Error registering selendroid into grid hub.\", e);\n+\n+      class GridRegistrationTask extends TimerTask {\n+        private final SelendroidStandaloneDriver driver;\n+        private final SelendroidConfiguration configuration;\n+        private final Logger log = Logger.getLogger(GridRegistrationTask.class.getName());\n+        private boolean firstTime = true;\n+\n+        GridRegistrationTask(SelendroidStandaloneDriver driver, SelendroidConfiguration configuration) {\n+          this.driver = driver;                // passing reference to driver and config\n+          this.configuration = configuration;  // as, let's say, config might change during runtime... (device quantity)\n+        }\n+\n+        @Override\n+        public void run() {\n+          try {\n+            final SelfRegisteringRemote remote = new SelfRegisteringRemote(configuration, driver);\n+\n+            if (firstTime) {","path":"selendroid-standalone/src/main/java/io/selendroid/standalone/server/SelendroidStandaloneServer.java","position":41,"original_position":41,"commit_id":"6a6ba71c8321695b72310ac13d8db5aa627a4477","original_commit_id":"6a6ba71c8321695b72310ac13d8db5aa627a4477","user":{"login":"frolix","id":3276590,"avatar_url":"https://avatars.githubusercontent.com/u/3276590?v=3","gravatar_id":"","url":"https://api.github.com/users/frolix","html_url":"https://github.com/frolix","followers_url":"https://api.github.com/users/frolix/followers","following_url":"https://api.github.com/users/frolix/following{/other_user}","gists_url":"https://api.github.com/users/frolix/gists{/gist_id}","starred_url":"https://api.github.com/users/frolix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frolix/subscriptions","organizations_url":"https://api.github.com/users/frolix/orgs","repos_url":"https://api.github.com/users/frolix/repos","events_url":"https://api.github.com/users/frolix/events{/privacy}","received_events_url":"https://api.github.com/users/frolix/received_events","type":"User","site_admin":false},"body":"@asm89, the check for firstTime is a kind of '--force-register' mode. The filed use for this is - let's say, you would like to restart selendroid for some reason (upgrade or config changes - emulators/devices/other grid parameters). And selendroid restarted quite fast, so grid hub have not noticed that selendroid node was absent. Then without this '--force-register' mode, the selendroid node will not send new config to grid hub.","created_at":"2015-01-08T10:29:42Z","updated_at":"2015-01-08T10:29:42Z","html_url":"https://github.com/selendroid/selendroid/pull/756#discussion_r22644485","pull_request_url":"https://api.github.com/repos/selendroid/selendroid/pulls/756","_links":{"self":{"href":"https://api.github.com/repos/selendroid/selendroid/pulls/comments/22644485"},"html":{"href":"https://github.com/selendroid/selendroid/pull/756#discussion_r22644485"},"pull_request":{"href":"https://api.github.com/repos/selendroid/selendroid/pulls/756"}}},"pull_request":{"url":"https://api.github.com/repos/selendroid/selendroid/pulls/756","id":26176833,"html_url":"https://github.com/selendroid/selendroid/pull/756","diff_url":"https://github.com/selendroid/selendroid/pull/756.diff","patch_url":"https://github.com/selendroid/selendroid/pull/756.patch","issue_url":"https://api.github.com/repos/selendroid/selendroid/issues/756","number":756,"state":"open","locked":false,"title":"Grid auto re-register","user":{"login":"frolix","id":3276590,"avatar_url":"https://avatars.githubusercontent.com/u/3276590?v=3","gravatar_id":"","url":"https://api.github.com/users/frolix","html_url":"https://github.com/frolix","followers_url":"https://api.github.com/users/frolix/followers","following_url":"https://api.github.com/users/frolix/following{/other_user}","gists_url":"https://api.github.com/users/frolix/gists{/gist_id}","starred_url":"https://api.github.com/users/frolix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frolix/subscriptions","organizations_url":"https://api.github.com/users/frolix/orgs","repos_url":"https://api.github.com/users/frolix/repos","events_url":"https://api.github.com/users/frolix/events{/privacy}","received_events_url":"https://api.github.com/users/frolix/received_events","type":"User","site_admin":false},"body":"If a grid hub was restarted, then SelendroidStandaloneServer will re-register itself again.\r\n\r\nCommit details:\r\n  a task created for self registration - first check grid if the node already registered, and re-register if not.\r\n  then the task is scheduled for execution (recurrence is configured via -registerCycle argument) \r\n\r\nA nice feature that I found useful when having a farm of selendroid-servers. :-)","created_at":"2014-12-16T20:27:14Z","updated_at":"2015-01-08T10:29:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"55b6ae121e35454db5ffa582c3ce2f6df18fb25e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/selendroid/selendroid/pulls/756/commits","review_comments_url":"https://api.github.com/repos/selendroid/selendroid/pulls/756/comments","review_comment_url":"https://api.github.com/repos/selendroid/selendroid/pulls/comments/{number}","comments_url":"https://api.github.com/repos/selendroid/selendroid/issues/756/comments","statuses_url":"https://api.github.com/repos/selendroid/selendroid/statuses/6a6ba71c8321695b72310ac13d8db5aa627a4477","head":{"label":"frolix:GridAutoRegister","ref":"GridAutoRegister","sha":"6a6ba71c8321695b72310ac13d8db5aa627a4477","user":{"login":"frolix","id":3276590,"avatar_url":"https://avatars.githubusercontent.com/u/3276590?v=3","gravatar_id":"","url":"https://api.github.com/users/frolix","html_url":"https://github.com/frolix","followers_url":"https://api.github.com/users/frolix/followers","following_url":"https://api.github.com/users/frolix/following{/other_user}","gists_url":"https://api.github.com/users/frolix/gists{/gist_id}","starred_url":"https://api.github.com/users/frolix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frolix/subscriptions","organizations_url":"https://api.github.com/users/frolix/orgs","repos_url":"https://api.github.com/users/frolix/repos","events_url":"https://api.github.com/users/frolix/events{/privacy}","received_events_url":"https://api.github.com/users/frolix/received_events","type":"User","site_admin":false},"repo":{"id":27764190,"name":"selendroid","full_name":"frolix/selendroid","owner":{"login":"frolix","id":3276590,"avatar_url":"https://avatars.githubusercontent.com/u/3276590?v=3","gravatar_id":"","url":"https://api.github.com/users/frolix","html_url":"https://github.com/frolix","followers_url":"https://api.github.com/users/frolix/followers","following_url":"https://api.github.com/users/frolix/following{/other_user}","gists_url":"https://api.github.com/users/frolix/gists{/gist_id}","starred_url":"https://api.github.com/users/frolix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frolix/subscriptions","organizations_url":"https://api.github.com/users/frolix/orgs","repos_url":"https://api.github.com/users/frolix/repos","events_url":"https://api.github.com/users/frolix/events{/privacy}","received_events_url":"https://api.github.com/users/frolix/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/frolix/selendroid","description":"\"Selenium for Android\" (Test automate native or hybrid Android apps and the mobile web with Selendroid.) Join us on IRC #selendroid on freenode. Also confirm you have signed the CLA http://goo.gl/pAvxEI when making a Pull Request.","fork":true,"url":"https://api.github.com/repos/frolix/selendroid","forks_url":"https://api.github.com/repos/frolix/selendroid/forks","keys_url":"https://api.github.com/repos/frolix/selendroid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frolix/selendroid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frolix/selendroid/teams","hooks_url":"https://api.github.com/repos/frolix/selendroid/hooks","issue_events_url":"https://api.github.com/repos/frolix/selendroid/issues/events{/number}","events_url":"https://api.github.com/repos/frolix/selendroid/events","assignees_url":"https://api.github.com/repos/frolix/selendroid/assignees{/user}","branches_url":"https://api.github.com/repos/frolix/selendroid/branches{/branch}","tags_url":"https://api.github.com/repos/frolix/selendroid/tags","blobs_url":"https://api.github.com/repos/frolix/selendroid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frolix/selendroid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frolix/selendroid/git/refs{/sha}","trees_url":"https://api.github.com/repos/frolix/selendroid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frolix/selendroid/statuses/{sha}","languages_url":"https://api.github.com/repos/frolix/selendroid/languages","stargazers_url":"https://api.github.com/repos/frolix/selendroid/stargazers","contributors_url":"https://api.github.com/repos/frolix/selendroid/contributors","subscribers_url":"https://api.github.com/repos/frolix/selendroid/subscribers","subscription_url":"https://api.github.com/repos/frolix/selendroid/subscription","commits_url":"https://api.github.com/repos/frolix/selendroid/commits{/sha}","git_commits_url":"https://api.github.com/repos/frolix/selendroid/git/commits{/sha}","comments_url":"https://api.github.com/repos/frolix/selendroid/comments{/number}","issue_comment_url":"https://api.github.com/repos/frolix/selendroid/issues/comments/{number}","contents_url":"https://api.github.com/repos/frolix/selendroid/contents/{+path}","compare_url":"https://api.github.com/repos/frolix/selendroid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frolix/selendroid/merges","archive_url":"https://api.github.com/repos/frolix/selendroid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frolix/selendroid/downloads","issues_url":"https://api.github.com/repos/frolix/selendroid/issues{/number}","pulls_url":"https://api.github.com/repos/frolix/selendroid/pulls{/number}","milestones_url":"https://api.github.com/repos/frolix/selendroid/milestones{/number}","notifications_url":"https://api.github.com/repos/frolix/selendroid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frolix/selendroid/labels{/name}","releases_url":"https://api.github.com/repos/frolix/selendroid/releases{/id}","created_at":"2014-12-09T11:49:23Z","updated_at":"2014-12-16T19:49:41Z","pushed_at":"2014-12-17T06:19:40Z","git_url":"git://github.com/frolix/selendroid.git","ssh_url":"git@github.com:frolix/selendroid.git","clone_url":"https://github.com/frolix/selendroid.git","svn_url":"https://github.com/frolix/selendroid","homepage":"http://selendroid.io","size":13816,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"selendroid:master","ref":"master","sha":"293ac9e30ae19a8e14c4cfb1c8dd8ef3a03dd5ce","user":{"login":"selendroid","id":3197580,"avatar_url":"https://avatars.githubusercontent.com/u/3197580?v=3","gravatar_id":"","url":"https://api.github.com/users/selendroid","html_url":"https://github.com/selendroid","followers_url":"https://api.github.com/users/selendroid/followers","following_url":"https://api.github.com/users/selendroid/following{/other_user}","gists_url":"https://api.github.com/users/selendroid/gists{/gist_id}","starred_url":"https://api.github.com/users/selendroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selendroid/subscriptions","organizations_url":"https://api.github.com/users/selendroid/orgs","repos_url":"https://api.github.com/users/selendroid/repos","events_url":"https://api.github.com/users/selendroid/events{/privacy}","received_events_url":"https://api.github.com/users/selendroid/received_events","type":"Organization","site_admin":false},"repo":{"id":7465720,"name":"selendroid","full_name":"selendroid/selendroid","owner":{"login":"selendroid","id":3197580,"avatar_url":"https://avatars.githubusercontent.com/u/3197580?v=3","gravatar_id":"","url":"https://api.github.com/users/selendroid","html_url":"https://github.com/selendroid","followers_url":"https://api.github.com/users/selendroid/followers","following_url":"https://api.github.com/users/selendroid/following{/other_user}","gists_url":"https://api.github.com/users/selendroid/gists{/gist_id}","starred_url":"https://api.github.com/users/selendroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selendroid/subscriptions","organizations_url":"https://api.github.com/users/selendroid/orgs","repos_url":"https://api.github.com/users/selendroid/repos","events_url":"https://api.github.com/users/selendroid/events{/privacy}","received_events_url":"https://api.github.com/users/selendroid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/selendroid/selendroid","description":"\"Selenium for Android\" (Test automate native or hybrid Android apps and the mobile web with Selendroid.) Join us on IRC #selendroid on freenode. Also confirm you have signed the CLA http://goo.gl/pAvxEI when making a Pull Request.","fork":false,"url":"https://api.github.com/repos/selendroid/selendroid","forks_url":"https://api.github.com/repos/selendroid/selendroid/forks","keys_url":"https://api.github.com/repos/selendroid/selendroid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/selendroid/selendroid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/selendroid/selendroid/teams","hooks_url":"https://api.github.com/repos/selendroid/selendroid/hooks","issue_events_url":"https://api.github.com/repos/selendroid/selendroid/issues/events{/number}","events_url":"https://api.github.com/repos/selendroid/selendroid/events","assignees_url":"https://api.github.com/repos/selendroid/selendroid/assignees{/user}","branches_url":"https://api.github.com/repos/selendroid/selendroid/branches{/branch}","tags_url":"https://api.github.com/repos/selendroid/selendroid/tags","blobs_url":"https://api.github.com/repos/selendroid/selendroid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/selendroid/selendroid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/selendroid/selendroid/git/refs{/sha}","trees_url":"https://api.github.com/repos/selendroid/selendroid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/selendroid/selendroid/statuses/{sha}","languages_url":"https://api.github.com/repos/selendroid/selendroid/languages","stargazers_url":"https://api.github.com/repos/selendroid/selendroid/stargazers","contributors_url":"https://api.github.com/repos/selendroid/selendroid/contributors","subscribers_url":"https://api.github.com/repos/selendroid/selendroid/subscribers","subscription_url":"https://api.github.com/repos/selendroid/selendroid/subscription","commits_url":"https://api.github.com/repos/selendroid/selendroid/commits{/sha}","git_commits_url":"https://api.github.com/repos/selendroid/selendroid/git/commits{/sha}","comments_url":"https://api.github.com/repos/selendroid/selendroid/comments{/number}","issue_comment_url":"https://api.github.com/repos/selendroid/selendroid/issues/comments/{number}","contents_url":"https://api.github.com/repos/selendroid/selendroid/contents/{+path}","compare_url":"https://api.github.com/repos/selendroid/selendroid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/selendroid/selendroid/merges","archive_url":"https://api.github.com/repos/selendroid/selendroid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/selendroid/selendroid/downloads","issues_url":"https://api.github.com/repos/selendroid/selendroid/issues{/number}","pulls_url":"https://api.github.com/repos/selendroid/selendroid/pulls{/number}","milestones_url":"https://api.github.com/repos/selendroid/selendroid/milestones{/number}","notifications_url":"https://api.github.com/repos/selendroid/selendroid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/selendroid/selendroid/labels{/name}","releases_url":"https://api.github.com/repos/selendroid/selendroid/releases{/id}","created_at":"2013-01-06T08:29:32Z","updated_at":"2015-01-07T06:26:39Z","pushed_at":"2015-01-06T23:37:18Z","git_url":"git://github.com/selendroid/selendroid.git","ssh_url":"git@github.com:selendroid/selendroid.git","clone_url":"https://github.com/selendroid/selendroid.git","svn_url":"https://github.com/selendroid/selendroid","homepage":"http://selendroid.io","size":18033,"stargazers_count":280,"watchers_count":280,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":166,"mirror_url":null,"open_issues_count":144,"forks":166,"open_issues":144,"watchers":280,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/selendroid/selendroid/pulls/756"},"html":{"href":"https://github.com/selendroid/selendroid/pull/756"},"issue":{"href":"https://api.github.com/repos/selendroid/selendroid/issues/756"},"comments":{"href":"https://api.github.com/repos/selendroid/selendroid/issues/756/comments"},"review_comments":{"href":"https://api.github.com/repos/selendroid/selendroid/pulls/756/comments"},"review_comment":{"href":"https://api.github.com/repos/selendroid/selendroid/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/selendroid/selendroid/pulls/756/commits"},"statuses":{"href":"https://api.github.com/repos/selendroid/selendroid/statuses/6a6ba71c8321695b72310ac13d8db5aa627a4477"}}}}