{"id":16758519,"url":"https://github.com/kessler/clusterize","last_synced_at":"2025-03-16T08:20:56.393Z","repository":{"id":142618754,"uuid":"5840368","full_name":"kessler/clusterize","owner":"kessler","description":"a simple node cluster helper","archived":false,"fork":false,"pushed_at":"2013-06-22T16:33:39.000Z","size":145,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T08:12:39.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/kessler.png","metadata":{"files":{"readme":"README.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}},"created_at":"2012-09-17T12:03:43.000Z","updated_at":"2013-10-13T14:34:37.000Z","dependencies_parsed_at":"2023-03-22T11:33:03.865Z","dependency_job_id":null,"html_url":"https://github.com/kessler/clusterize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fclusterize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fclusterize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fclusterize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fclusterize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kessler","download_url":"https://codeload.github.com/kessler/clusterize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243842132,"owners_count":20356610,"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":[],"created_at":"2024-10-13T04:05:35.050Z","updated_at":"2025-03-16T08:20:56.365Z","avatar_url":"https://github.com/kessler.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"klusterize\n==========\n\na node cluster helper\n\n###Usage\ntypical server.js:\n```\nvar klusterize = require('klusterize');\n\nklusterize({\n\tworker: function() {\n\t    console.log('I am a worker');\n\t},\n\tmaster: function() {\n\t\tconsole.log('I am the master');\n\t},\n\treforkOnDeath: false,\n\tworkersToCoresRatio: 0.5\n});\n\n//on a 4 cores system will (eventually) print 'I am a worker' twice and 'I am the master' once\n\n```\nSame as the above only this time called directly:\n```\nvar klusterize = require('klusterize');\n\nklusterize(\n\tfunction() {\n\t    console.log('I am a worker');\n\t}, \n\tfunction() {\n\t\tconsole.log('I am the master');\n\t},\n\tfalse,\n\t0.5);\n```\nfiles instead of functions:\n```\nvar klusterize = require('klusterize');\n\nklusterize({\n\tworker: 'worker.js',\n\tmaster: 'master.js'\n});\n```\n\n### options reference:\n- *worker*            - required, a function to invoke on worker processes or a name of a javascript filename\n\n- *master*            - optional, will be fired after forking code, can be a function or a javascript filename\n\n- *reforkOnDeath*       - optional, whether to refork processes when a worker dies, defaults to true\n\n- *workersToCoresRatio* - optional, workers to cores ratio expressed in numerical notation \n                            (i.e 0.5 = 50% of the cores etc.), default is 1 (100%). In any case there will\n\t                        always be a minimum of one worker. Values over 100% are acceptable and will spawn more workers than cores. \n\t                        The calculation will round the result down (i.e on a system with 5 cores, 0.5 will be rounded down to 2)\n\n- *workersCount*        - optional, en explicit number of worker to start, this will override workersToCoresRatio.\n                            as with workerstoCoresRation a minumum of 1 worker is enforced.\n\n- *workerDeathCallback* - optional, a callback to invoke on worker death. specifying this param will override\n\t                        reforkOnDeath behavior.\n\n- *env* \t\t\t\t- optional, environment of the worker\n\n###TODO\nexpand tests","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkessler%2Fclusterize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkessler%2Fclusterize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkessler%2Fclusterize/lists"}