{"action":"created","issue":{"url":"https://api.github.com/repos/eggjs/egg/issues/2538","repository_url":"https://api.github.com/repos/eggjs/egg","labels_url":"https://api.github.com/repos/eggjs/egg/issues/2538/labels{/name}","comments_url":"https://api.github.com/repos/eggjs/egg/issues/2538/comments","events_url":"https://api.github.com/repos/eggjs/egg/issues/2538/events","html_url":"https://github.com/eggjs/egg/issues/2538","id":321901347,"number":2538,"title":"请问手动启动egg时如何才能得到application对象?","user":{"login":"xingyuzhe","id":3498363,"avatar_url":"https://avatars2.githubusercontent.com/u/3498363?v=4","gravatar_id":"","url":"https://api.github.com/users/xingyuzhe","html_url":"https://github.com/xingyuzhe","followers_url":"https://api.github.com/users/xingyuzhe/followers","following_url":"https://api.github.com/users/xingyuzhe/following{/other_user}","gists_url":"https://api.github.com/users/xingyuzhe/gists{/gist_id}","starred_url":"https://api.github.com/users/xingyuzhe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xingyuzhe/subscriptions","organizations_url":"https://api.github.com/users/xingyuzhe/orgs","repos_url":"https://api.github.com/users/xingyuzhe/repos","events_url":"https://api.github.com/users/xingyuzhe/events{/privacy}","received_events_url":"https://api.github.com/users/xingyuzhe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-10T11:36:30Z","updated_at":"2018-05-10T12:57:36Z","closed_at":null,"author_association":"NONE","body":"### bin/run.ts:\r\n```\r\nconst masterInstance = new Master({\r\n  workers: 1,\r\n  baseDir\r\n})\r\n\r\nmasterInstance.ready(async () => {\r\n  // 这里可以得到master, agent, app进程\r\n  // ... 但是如何得到创建的application对象呢?\r\n  await app.doSomething()\r\n  app.close()\r\n})\r\n```\r\n\r\n### package.json\r\n```\r\ncmd-xxx:  \"ts-node bin/run.ts\" \r\n```\r\n\r\n是这样,  我想在application环境下处理一些任务, 但是只是作为package.json里的一条命令执行, 不对其它地方造成影响。所以我需要手动启动egg。之前我移除了cluster模块直接启动application是可以的。 但是直接使用egg的话, 只能通过cluster启动；但是我不知如何才能得到application对象。\r\n\r\n如果有别的独立运行egg的方式也请赐教"},"comment":{"url":"https://api.github.com/repos/eggjs/egg/issues/comments/388045537","html_url":"https://github.com/eggjs/egg/issues/2538#issuecomment-388045537","issue_url":"https://api.github.com/repos/eggjs/egg/issues/2538","id":388045537,"user":{"login":"atian25","id":227713,"avatar_url":"https://avatars2.githubusercontent.com/u/227713?v=4","gravatar_id":"","url":"https://api.github.com/users/atian25","html_url":"https://github.com/atian25","followers_url":"https://api.github.com/users/atian25/followers","following_url":"https://api.github.com/users/atian25/following{/other_user}","gists_url":"https://api.github.com/users/atian25/gists{/gist_id}","starred_url":"https://api.github.com/users/atian25/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atian25/subscriptions","organizations_url":"https://api.github.com/users/atian25/orgs","repos_url":"https://api.github.com/users/atian25/repos","events_url":"https://api.github.com/users/atian25/events{/privacy}","received_events_url":"https://api.github.com/users/atian25/received_events","type":"User","site_admin":false},"created_at":"2018-05-10T12:57:36Z","updated_at":"2018-05-10T12:57:36Z","author_association":"OWNER","body":"> 我想在application环境下处理一些任务, 但是只是作为package.json里的一条命令执行, 不对其它地方造成影响。\r\n\r\n没看懂"}}
{"actor":{"display_login":"atian25"}}