{"action":"created","issue":{"url":"https://api.github.com/repos/Block8/PHPCI/issues/864","labels_url":"https://api.github.com/repos/Block8/PHPCI/issues/864/labels{/name}","comments_url":"https://api.github.com/repos/Block8/PHPCI/issues/864/comments","events_url":"https://api.github.com/repos/Block8/PHPCI/issues/864/events","html_url":"https://github.com/Block8/PHPCI/pull/864","id":60618424,"number":864,"title":"Refactored the run-builds, rebuild and daemonise commands.","user":{"login":"Adirelle","id":24633,"avatar_url":"https://avatars.githubusercontent.com/u/24633?v=3","gravatar_id":"","url":"https://api.github.com/users/Adirelle","html_url":"https://github.com/Adirelle","followers_url":"https://api.github.com/users/Adirelle/followers","following_url":"https://api.github.com/users/Adirelle/following{/other_user}","gists_url":"https://api.github.com/users/Adirelle/gists{/gist_id}","starred_url":"https://api.github.com/users/Adirelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Adirelle/subscriptions","organizations_url":"https://api.github.com/users/Adirelle/orgs","repos_url":"https://api.github.com/users/Adirelle/repos","events_url":"https://api.github.com/users/Adirelle/events{/privacy}","received_events_url":"https://api.github.com/users/Adirelle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-03-11T06:58:26Z","updated_at":"2015-04-08T06:51:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Block8/PHPCI/pulls/864","html_url":"https://github.com/Block8/PHPCI/pull/864","diff_url":"https://github.com/Block8/PHPCI/pull/864.diff","patch_url":"https://github.com/Block8/PHPCI/pull/864.patch"},"body":"This a refactorisation of these commands, it consists of the following modifications:\r\n* The former RunCommand->execute method has been split into smaller methods: setupLogging, findNextBuild and runBuild.\r\n* I got rid of all instance attributes but $logger; they were not necessary and created some confusion.\r\n* RunCommand->runBuild *always* pops the build logger and *always* removes the build directory.\r\n* DaemoniseCommand and RebuildCommand now inherits from RunCommand instead of creating an instance; their execute method simply reuses the new methods to implement a different logic.\r\n\r\nThe command logic is now:\r\n* RunCommand: \r\n  * Runs up to maxBuilds (default 100) builds, one at a time. \r\n  * Verifies running builds and looks for a pending build at each iteration (instead of finding all pending builds at the start).\r\n  * Ends as soon as there is nothing to do. This fixes an issue where the RunCommand goes in a very short loop, doing requests and spitting in the log files at a very fast pace.\r\n* DaemoniseCommand:\r\n  * Runs indefinitely.\r\n  * Sleeps where there is nothing to do, using an incremental duration.\r\n* RebuildCommand:\r\n  * Duplicates the latest build and build it immediately, bypassing all restrictions.\r\n\r\nI would like to add POSIX process control (handling signals, tracking build PIDs and killing them when they time out) but that would not work on Windows; another solution could be to use the proc_* family of functions to do so. Any thought on this ?"},"comment":{"url":"https://api.github.com/repos/Block8/PHPCI/issues/comments/90822501","html_url":"https://github.com/Block8/PHPCI/pull/864#issuecomment-90822501","issue_url":"https://api.github.com/repos/Block8/PHPCI/issues/864","id":90822501,"user":{"login":"Adirelle","id":24633,"avatar_url":"https://avatars.githubusercontent.com/u/24633?v=3","gravatar_id":"","url":"https://api.github.com/users/Adirelle","html_url":"https://github.com/Adirelle","followers_url":"https://api.github.com/users/Adirelle/followers","following_url":"https://api.github.com/users/Adirelle/following{/other_user}","gists_url":"https://api.github.com/users/Adirelle/gists{/gist_id}","starred_url":"https://api.github.com/users/Adirelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Adirelle/subscriptions","organizations_url":"https://api.github.com/users/Adirelle/orgs","repos_url":"https://api.github.com/users/Adirelle/repos","events_url":"https://api.github.com/users/Adirelle/events{/privacy}","received_events_url":"https://api.github.com/users/Adirelle/received_events","type":"User","site_admin":false},"created_at":"2015-04-08T06:51:21Z","updated_at":"2015-04-08T06:51:21Z","body":"Considering several issues I've seen recently, I wondering about slightly rewriting this PR this way:\r\n* Have the phpci:daemonize commands just runs \"./daemonise phpci:run-builds; sleep 15\" in a infinite loop, without ever looking at the database. This should fix the issues about Project caching and stale Mysql connections.\r\n* Have the phpci:run-builds command run each build in a separate sub-command. This should ensure build isolation and we could eventually track the builds using PIDs. However, we would run into trouble if run-builds had to modify the Build object after launching the sub-command, as it would work with a stale Build object.\r\n* Maybe add a ProcessControl helper with two methods -- isRunning($pid) and kill($pid, $signal) -- and different implementations depending on installed extensions and the OS, to help tracking and checking processes in the previous rewrites.\r\n\r\nShould I close this PR and open a new one or rewrite it ?\r\n"}}