简体   繁体   English

如何将node.js和节点应用程序部署到嵌入式目标?

[英]How to deploy node.js and node application to embedded target?

I have a node.js application that I've developed for our custom Arm/Debian board, currently running on an SD card. 我有一个为自定义Arm / Debian开发板开发的node.js应用程序,当前在SD卡上运行。 For production, I will be deploying this on our board's eMMC. 对于生产,我将在董事会的eMMC上进行部署。 We've written a script to copy our OS/filesystem/device tree to the eMMC, so we can successfully boot and run our system - but it lacks node and any custom code. 我们已经编写了一个脚本将OS /文件系统/设备树复制到eMMC,因此我们可以成功地启动和运行我们的系统-但是它缺少节点和任何自定义代码。 From the base OS, I currently manually build node and copy the necessary source files - so I could write the script for this. 目前,在基本操作系统中,我手动构建节点并复制必要的源文件-因此我可以为此编写脚本。

But I am wondering if there is a way to automate the building of node and my application, so I can overcome the manual/script effort and time to set-up a production system? 但是我想知道是否有一种方法可以自动构建节点和应用程序,因此我可以克服建立生产系统所需的手动/脚本工作和时间吗? To reduce the time to building node and copying files (important if we have to mass produce), is it possible to copy/clone or tar/un-tar node and the associated app? 为了减少构建节点和复制文件的时间(如果必须批量生产,这一点很重要),是否可以复制/克隆或tar / un-tar节点以及相关的应用程序? Is there a best method for this type of problem? 有没有针对此类问题的最佳方法?

I ended up writing a script that copies node and my node application to the eMMC. 我最终写了一个脚本,将节点和我的节点应用程序复制到eMMC。 Between Dominic Tancredi's answer here: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) and just general sleuthing, I was able to determine the directories I need to copy: 在Dominic Tancredi的回答之间: 如何完全卸载Node.js,然后从头开始安装(Mac OS X)并进行常规侦查,就能够确定需要复制的目录:

echo "Mounting eMMC for copying node.js and node app"
mkdir mnt
mount ${EMMCPARTITION} mnt || error_mount_emmc

echo "Copying node.js to eMMC partition"
cp -av /usr/local/lib/node_modules                  mnt/usr/local/lib/
cp -av /usr/local/include/node                      mnt/usr/local/include/
cp -av /usr/local/bin/node                          mnt/usr/local/bin/
cp -av /usr/local/bin/npm                           mnt/usr/local/bin/
mkdir -v mnt/usr/local/share/systemtap
mkdir -v mnt/usr/local/share/systemtap/tapset
cp -av /usr/local/share/systemtap/tapset/node.stp        
mnt/usr/local/share/systemtap/tapset/

echo "Copying node app to eMMC partition"
cp -av /home/debian/app                             mnt/home/debian/

echo "Release mnount of eMMC"
umount ${EMMCPARTITION}         || error_cp_emmc
rmdir mnt

I wish there was a documented way, but in the absence of that, I hope this is useful to others. 我希望有一个有据可查的方法,但是如果没有这种方法,我希望这对其他人有用。

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

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