Node.js Touchless (XCOPY) Install on Windows - javascript

This may be the wrong forum to ask this question, however is it possible to do a "touchless" node.js deployment? For example, is it possible to push a copy of node.exe and the required packages to a physical location on the drive (assume the machine is generally in a disconnected state) then have a shortcut that executes the appropriate commandline to get the node process running?
I know that this is a loaded question, because without being physically installed on the box, and then running within a Windows Service, you lose all the lifetime management, and that is just scratching the surface of the things that need to be considered. Anyway, I truly appreciate the help and opinions.

Just coming back to clean up this answer. Yes this is possible, but not always advisable. Better to do an installation or leverage containers.

Related

Git adding, committing, and pushing from a website

I'm making a website as a collaboration tool. Several people could be using it, and I need the ability to, from the website, be able to add, commit, and push to git for all users. I had several ideas, but don't know how they'll pan out. Here are some of them:
Create an external Python program waiting for an event from the website. Then the Python program could access the terminal on the local machine and run the necessary commands to add, commit, and push to git.
 The issue with that is that the Python program would have to be running constantly on the local machine of every user of the website. I don't plan to have too many, but I think this would be VERY inconvenient.
Use some complicated JavaScript program to scrape GitHub and automate add, commit, and push through there. Don't think this is a good idea, but I'm open to it.
Will any of these work for what I need? If so, how would I implement them? Is there a formal way of adding, committing, and pushing to Git over the internet that I'm oblivious to? I've done a ton of research and come up empty-handed.
EDIT
Somebody in the comments suggested using the Github API. I didn't find anything useful, but if I'm not seeing something please point it out. I'm specifically looking for something to replace the usual git add ., git commit -m "message" and git push commands, but for my website to automate this.

How to use fonts in the node.js backend?

Background:
I am building a node.js-based Web app that needs to make use of various fonts. But it only needs to do so in the backend since the results will be delivered as an image. Consequently, the client/browser does not need access to the fonts at all in my case.
Question:
I will try to formulate the question as little subjective as possible:
What are the typical options to provide a node.js backend with a large collection of fonts?
The options I came up with so far are:
Does one install these hundreds or thousands of fonts in the operating system of the (in my case: Ubuntu) server?
Does one somehow serve the fonts from a cloud storage such as S3 or (online) database such as a Mongo DB server?
Does one use a local file system to store the fonts and retrieve them?
...other options
I am currently leaning towards Option 1 because this is the way a layman like me does it on a local machine.
Without starting a discussion here, where could I find resources discussing the (dis-)advantages of the different options?
EDIT:
Thank you for all the responses.
Thanks to these, I noticed that I need to clarify something. I need the fonts to be used in SVG processing libraries such as p5.js, paper.js, raphael.js. So I need to make the fonts available to these libraries that are run on node.js.
The key to your question is
hundreds or thousands of fonts
Until I took that in there is no real difference between your methods. But if that number is correct (kind of mind-boggling though) I would:
not install them in the OS. What happens if you move servers without an image? Or move OS?
Local File system would be a sane way of doing it, though you would need to keep track manually of all the file names and paths for your code.
MongoDB - store file names+paths in the collection..and store the actual fonts in your system.
In advent of moving servers you would have to pick up the directory where all the actual files are stored and the DB where you hold the file name+paths.
If you want you can place it all in a MongoDB but then that file would also be huge, I assume - that is up to you.
Choice #3 is probably what I would do in such a case.
If you have a decent enough server setup (e.g. a VPS or some other VM solution where you control what's installed) then another option you might want to consider is to do this job "out of node". For instance, in one of my projects where I need to build 175+ as-perfect-as-can-be maths statements, I offload that work to XeLaTeX instead:
I run a node script that takes the input text and builds a small but complete .tex file
I then tell node to call "xelatex theFileIJustMade.tex" which yields a pdf
I then tell node to call "pdfcrop" on that pdf, to remove the margins
I then tell node to call "pdf2svg", which is a free and amazingly effective utility
Then as a final step mostly to conserve space and bandwidth, I use "svgo" which is a nodejs based svg optimizer that can run either as normal script code, or as CLI utility.
(some more details on that here, with concrete code here)
Of course, depending on how responsive a system you need, you can do entirely without steps 3 and 5. There is a limit to how fast we can run, but as a server-side task there should never be the expectation of real-time responsiveness.
This is a good example of remembering that your server runs inside a larger operating system that might also offer tools that can do the job. While you're using Node, and the obvious choice is a Node solution, Node is also a general purpose programming language and can call anything else through spawn and exec, much like python, php, java, C#, etc. As such, it's sometimes worth thinking about whether there might be another tool that is even better suited for your needs, especially when you're thinking about doing a highly specialized job like typesetting a string to SVG.
In this case, LaTeX was specifically created to typeset text from the command line, and XeLaTeX was created to do that with full Unicode awareness and clean, easy access to fonts both from file and from the system, with full OpenType feature control, so would certainly qualify as just as worthwhile a candidate as any node-specific solution might be.
As for the tools used: XeLaTeX and pdfcrop come with TeX Live (installed using whatever package manager your OS uses, or through MiKTeX on Windows, but I suspect your server doesn't run on windows) pdf2svg is freely available on github, and svgo is available from npm)

Save file change on heroku

I hava a node.js app on heroku thath checks for emails and then if the email match certian cliteria it would reply.
Because heroku restarts the dyno every so often I made a file that saves the ids of the emails (a small array) I've already cheaked (so it doesn't reply twice to the same email), but silly me, heroku restarts that file too, so no changes I made will be save.
Is there a way to save the file changes the app makes to it?
If you know of a better way of to do what I want to?
Heroku enforces this behavior (the local file deletion stuff) because it is a best practice. Writing files locally doesn't scale well, and can lead to some odd edge-case behaviors when you have multiple processes on the same VM all performing file I/O operations.
What you should use instead is either a database, a cache (like Redis), or even just write your file directly to a file storage service like Amazon S3.
I realize it sounds annoying that you have to do these extra things even for a simple use case like what you're doing here -- but Heroku's platform is geared around enforcing best practices to help people build scalable, reliable software.
If you're looking for a way to do stuff like this without the extra hassle, you might want to consider just purchasing a small VPS server from another company where you can have direct control over processes, disk, etc.

Node.js - Taking it public?

I'm learning how to program in Node.js, and so far I've been able to run it using my computer as a server, and log in through an IP address:8080 from other computers on the same router. But for the life of me, I can't seem to find any tutorials or anything for taking it public. E.g using my laptop from work to connect to the server hosted at home. I've searched free servers and am completely mixed up on SSH keys and github requirements and stuff with a bunch of others. I'm really mixed up.
I'm also thinking it would be much simpler (and 100% free on monthly payments) to buy my own hardware and run my own servers? Any tutorials on node.js hardware set ups?
Please help, I'm completely confused.
EDIT
I seem to have been a bit unclear. I'm going to use node.js to make games/apps with logins. When you "login" you automatically login to the server also. Not only from "work to home", I meant completely public as a multiplayer game.
One easy way to setup a node server for free is using AWS Free Tier.
Once you follow that link and setup a server...
You can follow along with this tutorial to get your server up and going, install node, install mongodb and even make an app that will run on the live server.
Run throgh this tutorial
How I installed node on my server,
Personally I have a VPS from Bluehost. This cost me about $120 a month but lets me do whatever I want with my server. By whatever I want I mean install whatever I want...
I have npm install,
I installed node.js globally.
I installed mongoDB.
I can run mongodb applications from anywhere and connect them to the MongoDB running on my server.
Having a VPS can come in handy as you can see... I suggest AWS free tier. Learn how to install all the things you want. Play with it. Break it and start over.
But when your done with all of that...
Be a Jedi Master!
Node doesn't have any specific hardware requirements or configuration. And can be hosted on anything.
I guess you don't have a dedicated ip address. So, your question seems to be all about network, routing and dealing with NAT. If you're not familiar with those, it might be not a bad idea to use external hosting.
But if you want to give it a try, this might be helpful - https://superuser.com/questions/121435/is-it-possible-to-host-a-web-server-from-behind-a-nat
Besides hosting your own hardware, there are 2 options for what you describe.
One, use a portforwarding tool to make your home server accessible from your work, for example ngrok.
Two, deploy your node.js app to an online platform, for example OpenShift or Heroku. Most of these platforms have a low-performance free options.

Is that possible to develop a ACM ONLINE JUDGE system using NODE.JS(or PYTHON)?

I'm a newer and if the question is so easy I apologize for that.
Assume I want to dev a classical online judge system, obviously the core part is
get users' code to a file
compile it on server
run it on server (with some sandbox things to prevent damage)
the program exit itself, then check the answer.
or get the signal of program collapsing.
I wonder if it's possible to do all the things using Node.js, how to do the sandbox things. Is there any example for compile-sandbox-run-abort-check thing?
additional:
is it more convenient to dev a such system using PYTHON?
thanks in advance.
Most of these steps are standard --- create a file, run a system call to compile something, muck around with I/O --- I think any language should be able to do them, except the very crucial step of "run in a sandbox." I am aware of several solutions for sandboxing:
use OS commands to restrict or remove abilities (chroot, setrlimit, file system permissions in linux)
remove all dangerous functionality from the language being graded
interrupt system events
run the sandbox inside a virtual machine.
This list is probably not exhaustive. The system I am involved with, http://cscircles.cemc.uwaterloo.ca uses option #1. Again, most of the work is done in system calls so I can't imagine that one language is so much better than the other? We use php for the big-level stuff and C to do the sandboxing. Does that help answer your question?
To accomplish the sandbox, it would be fairly easy to do this by simply running your code inside of a closure that reassigns all of the worrisome calls to NaN
for instance, if the code executes inside a closure where eval=NaN

Categories