简体   繁体   English

将sails.js应用程序作为Azure WebJob运行

[英]Running sails.js app as Azure WebJob

I currently have a Sails.js backend-only app that, every hour: 我目前有一个Sails.js后端应用程序,每小时:

  • fetches a given World of Warcraft realm's AH dump 获取给定的魔兽世界境界的AH转储
  • processes it 处理它
  • removes the old dump from the DB 从数据库中删除旧转储
  • outputs both the dump and the job result to the DB. 将转储和作业结果输出到DB。

I've found out that Azure WebJobs would make this easier, since I'd not need to manually code which realms to cover or the scheduling itself. 我发现Azure WebJobs会使这更容易,因为我不需要手动编码要覆盖的域或调度本身。

Is there any way to turn an Sails.js app into a WebJob? 有没有办法将Sails.js应用程序转换为WebJob? Or should I be using Waterline itself for the DB access and coding everything else manually? 或者我应该使用Waterline本身进行数据库访问并手动编码其他所有内容?

I'm not familiar with Sails.js per se, but in general if you can extract your logic into a nodejs console app that you can run on your machine, then it should work as a webjob. 我本身并不熟悉Sails.js,但总的来说,如果你可以将你的逻辑提取到你可以在你的机器上运行的nodejs控制台应用程序,那么它应该作为webjob工作。 All you would need to do is upload the full directory, that's including all the node_modules and all the .js files, make sure your entry point is set in a file called run.js and you should be set. 您需要做的就是上传完整目录,包括所有node_modules和所有.js文件,确保您的入口点设置在名为run.js的文件中,您应该进行设置。

If you want it to be triggered on a schedule, include a file called settings.job that contains your schedule in the following format 如果您希望按计划触发它,请按以下格式包含名为settings.job的文件,其中包含您的计划

{"schedule": "cron expression for the schedule"}

for hourly the cron expression would be 0 * * * * * 每小时cron表达式为0 * * * * *

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM