How to cancel build automatically upon Sublime Text 3 exit? - sublimetext3

Is there a way to ensure build is automatically cancelled upon ST3 exit if I forgot to manually do so? This is especially important for long-running tasks such as a live-update nodejs process for react webpack development in my case. Without it, I found nodejs process will continue listen on the port, preventing same build from launching later, at least on Windows.

I'm not entirely sure if this approach will work with node.js, but if I have a Python script that is taking too long or has reached an infinite loop I will cancel the Python task in Task Manager. Try looking for a node.js task and see if that works.

Related

Python Code Running too fast and needs to be slowed down after PsUtil update

I have a python+pytest based automation system that runs on various windows machines a part of a CI pipeline. Earlier this month we upgraded one of the python modules (Psutils to verion 5.9.2) to it's latest version. from that moment on we are facing issues that look as if the python code is running too fast and we need to throtle it down. One of such cases is as follows:
Run a command that opens a process through subprocess.popen(...) command.
once the process is running get, the process's pid
List the DLLs inside the process. What usually would happen is that we would detect the needed DLL. Now after the upgrade we will not detect the needed DLL unless I would call for a sleep before calling subprocess.popen(...) method. When performing the same steps manually there is no problem, while if the code is running it's reproducible 100% of the times.

Prompt for User Input From Within a Subshell

I am using task to run various build steps in parallel. It is like 1000% faster then doing it all synchronously. However, it seems that task uses all these different subshells. I want to be able to prompt the user for their input using a node program. However, when node logs and attempts to prompt from task its restamped with tasks logger and I cannot get the fancy node prompt to show up.
I was wondering what the best way of solving this would be. Ideally, I could use a one-liner that attaches whatever code task runs to the main terminal Window so that the node script can do its thing. However, if that's not possible I'm open to other ideas. I was thinking of creating a bash alias for task that is the front end and then I could post the messages I want logged while node is listening to the socket that task posts onto. I just want to make sure there is no easy way of handling this before I create a custom solution.
Thanks.

What is the correct way to start and stop simple Node.js scripts

I'm trying to create a simple Twitter bot to learn some Node.js skills.
It works fine on my local computer. I start the script with node bot.js and then close it with Ctrl + C.
I've uploaded the files to a server (Krystal hosting). I've ssh'd into the server and then used $ source /home/[username]/nodevenv/twitterbot/10/bin/activate. Which I think puts me into a Node environment (I'm not really clear what is happening here).
From here I can run node bot.js. My Twitter bot runs fine and I can leave the terminal. What I've realised now is that I don't know how to stop this script.
Can someone explain how I should be doing this? Is there a command I can enter to stop the original bot.js process? Since looking into this it looks like perhaps I should have used something like pm2 process manager. Is this correct?
Any pointers would be much appreciated.
Thanks,
B
You can kill it externally by nuking the process from an OS command line or in an OS GUI (exact procedure varies by OS). Ctrl-C from the shell is one version of this, but it can be done without the command shell that it was started in too by nuking the process directly.
Or, you can add a control port (a simple little http server running on a port only accessible locally) that accepts commands that let you do all sorts of things with the server such as extract statistics, shut it down, change the configuration, tell it to clear caches so content updates take effect immediately, etc... Shutting down the server this way allows for a more orderly shut-down from code within the server. You can even stop accepting incoming connections, but wait for existing http connections to complete before shutting down, close databases normally, etc...
Or, you can use a monitoring program such as PM2 or forever that in addition to restarting the server automatically if it should ever crash, they also offer commands for shutting it down too (which will just send it certain signals kind of like Ctrl-C does).

NodeJS - Process Watcher

I was looking if there are any module that was able to start a process, in my case it would be a Binary File on a Unix system. I should be able to start, stop, restart and get the process status and if possible detect in real time when the process state changes (starting up or shutting down), I found some solutions but were not suitable, for example PM2 (they have a programmatically API) but I could not launch the binary file, I belive it only works for Node.js written applications. If someone knows a module or a simple and fast way to achieve this I would be thankfull.

Deploy node code without restart

According to Uber it's possible to deploy code to node without restart. Where can I read more about this? I expecting it's not forever or pm2.
That’s where the second strength Uber found in Node.js (quick iteration) comes into play:
through an interactive testing environment called REPL - Read Eval Print Loop - JavaScript allows
developers to deploy new code - and fix the errors that new code may create - without having to
stop any processes.
“One of the things that makes Node.js uniquely suited to running in production is that you can
inspect and change a program without restarting it,” said Ranney. “So very few other languages
offer that capability. Not a lot of people seem to know that ability exists, but indeed you can
inspect and even change your program while it’s running without restarting it.”
Source: https://nodejs.org/static/documents/casestudies/Nodejs-at-Uber.pdf

Resources