rrun+juicefs 进行nodejs 模块的运行

参考图

 

 

 

玩法说明

我们使用ncc 将开发的node 应该直接all-in-one,同时暴露一个默认的npm (cmd )实现,同时直接利用juicefs 的s3 endpoint 上传到s3 中,juicefs 会做为一个
sidecar 挂载到我们的rrun 运行时节点中(可以基于虚拟机,以及容器,都是不错的选择),之后就可以直接运行服务了

参考实例

  • package.json
 
{
  "name": "app-test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "hashids": "^2.2.10",
    "rrun": "^1.0.5"
  },
  "scripts": {
    "app": "rrun myapp/index.js",
    "build":"ncc build app.js -o myapp"
  },
  "devDependencies": {
    "@vercel/ncc": "^0.38.1"
  }
}
  • app.js
    集成hashids 同时暴露一个默认实现
 
const hashids = require("hashids")
module.exports = ()=>{
    let id   = new hashids("demoappaaa",100).encode(2222)
    console.log(id)
}
  • ncc 打包
ncc build app.js -o myapp
  • 运行
yarn app
  • 效果

 

 

说明

rrun 只是一个不错的基于命令行加载node 模块的方法,类似的工具比较多,或者自己写一个,而且如果能加载远端就更好了(同时包含权限控制的,这个可以自己编写),实际上以上玩法就有点serverless 的影子了,一些开源serverless 实现对于服务调用也是使用了类似的方法,github action 中使用nodejs 开发action 也是使用了类似的方法

参考资料

https://www.npmjs.com/package/rrun
https://deno.land/
https://juicefs.com/

posted on   荣锋亮  阅读(89)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-05-28 VictoriaMetrics v1.36.0 的一些新功能
2019-05-28 Kapitan 通用terraform&& kubernetes 配置管理工具
2019-05-28 sqler 集成 terraform v0.12 生成资源部署文件
2018-05-28 nexus helm proxy 集成&&问题解决
2018-05-28 nexus yum 私服集成
2018-05-28 nexus bower 集成使用
2018-05-28 nexus docker 私有镜像处理

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示