在单个函数调用中部署并运行代码。
aegisblade的Python项目详细描述
安装
我们建议使用virtualenv为python应用程序创建一个独立的环境。在
安装python包作为应用程序的依赖项。在
$ pip install aegisblade
或者对于python3
:
Hello World示例
const{aegisblade}=require('aegisblade');constos=require("os");/** * In this example the `helloWorld()` function will be run on a * server using AegisBlade. */asyncfunctionhelloWorld(){console.log(`The server's hostname is ${os.hostname()}`);return`Hello World from ${os.hostname()}`;}// Any target function to be run on AegisBlade must be exported.module.exports={helloWorld};/** * The `main()` function will run on your local machine * and start the job running the `helloWorld()` function * on a server using AegisBlade. */asyncfunctionmain(){letjob=awaitaegisblade.run(helloWorld);console.log(`Job Id: ${job.id}`);console.log("Waiting for the job to finish running...");letjobReturnValue=awaitjob.getReturnValue();letjobLogs=awaitjob.getLogs();console.log(`Job Return Value: ${jobReturnValue}`);console.log(`Job Logs: ${jobLogs}`);}// Using the `require.main === module` idiom to only run main when this script// is called directly is especially important when using AegisBlade to prevent// infinite loops of jobs creating jobs.if(require.main===module){(async()=>{try{awaitmain();}catch(err){console.error(err);}})();}
关于python2的注释
官方的python组织在2020年1月之后将不再支持python2。在
不过,由于它的流行用法,在可预见的将来,我们可能会继续支持Python2.7客户机。在
参考文献
联系人
盾形盾-@aegisbladehq-welovedevs@aegisblade.com
项目链接:https://github.com/aegisblade/aegis-nodejs
- 项目
标签: