How to schedule a task in Node.js that runs after script has exited? - node.js

In writing an Electron app, I've found the need to execute a background task that will run even when the UI has exited. An installer will be distributed to different computers, so I need a way to schedule a recurring task either in the installer or in code that gets run as part of the Electron app process. I've looked into libraries like bree and agenda, but I haven't been able to find a way to schedule in the aforementioned manner with these libraries.
How would I a) extend the functionality of the installer to schedule the task with native tools like Windows Task Scheduler or b) schedule this sort of recurrent task from my Electron app?

if you want to change the installer, then you need to investigate custom pages in NSH language to inbuild this functionality into electron-builder installer
this will be complicated
In my work I faced similar need and set a recurring task via windows scheduler tasks just by running a process command, please have a look at my code here:
https://github.com/beliaev-maksim/beta_build_downloader/blob/6b5fce4b675cc108e4048e7d65676133df0ef78e/electron_ui/js/tasks_handler.js#L61
same could be achieved using cron on Linux systems (but have to be installed on some distributions)
Do not forget to vote for the answer and mark as accepted if that helped you

Related

Is it possible to stream Cloud Build logs with the Node.js library?

Some context: Our Cloud Build process relies on manual triggers and about 8 substitutions to customize deploys to various firebase projects, hosting sites, and preview channels. Previously we used a bash script and gcloud to automate the selection of these substitution options, the "updating" of the trigger (via gcloud beta builds triggers import: our needs require us to use a single trigger, it's a long story), and the "running" of the trigger.
This bash script was hard to work with and improve, and through the import-run shenanigans actually led to some faulty deploys that caused all kinds of chaos: not great.
However, recently I found a way to pass substitution variables as part of a manual trigger operation using the Node.js library for Cloud Build (runTrigger with subs passed as part of the request)!
Problem: So I'm converting our build utility to Node, which is great, but as far as I can tell there isn't a native way to steam build logs from a running build in the console (except maybe with exec, but that feels hacky).
Am I missing something? Or should I be looking at one of the logging libraries?
I've tried my best scanning Google's docs and APIs (Cloud Build REST, the Node client library, etc.) but to no avail.

Is it possible to continue working in Revit while running a python script in pyrevit?

When running Revitpythonshell or running a python script with XAML gui I am unable to work in Revit until closing Revitpythonshell or the python gui.
Is there a way to keep Revit from becoming inaccessible like this?
I would like to keep my script open to continually use while I work.
You have a couple of options here depending on what your script is trying to do:
pyRevit has a 'non-modal' console that keeps Revit accessible.
Pythons threading module could be what youre looking for. You can automate alot of tasks in the background as you continue working, with one big caveat: Revit is a single-core program, so if you touch the database / API from another thread - Revit will crash.
You can start a process on a thread, then close the console. Your thread will continue to run - you just have to use winforms or another UI tool to let you know where the thread is up to. I use this to automate non-Database tasks that take 30-45 mins, while continuing to work in Revit.
If you need to keep accessing the Revit Database / API from your script, Id recommend making a simple UI and get it talking to an ExternalEvent in Revit. Here is a fantastic example of using a form with ExternalEvent by Cyril Waechter: pyRevit WPF non-modal trouble

Creating a Web UI for StrongLoop build & deploy processes?

I want to build web ui for StrongLoop. It would let a user build and deploy process with that UI like StrongLoop Arc.
There are simple node applications(Web Services) without created with StrongLoop tools. Need to deploy these applications via web ui. Solution in my mind is some server-side processes, listed steps below:
Upload zip folder(node application) to server
Extract zip and build to tar.gz by shell command (slc build) through node.js child_process API
Deploy tar.gz file to relevant StrongLoop host by shell command(slc deploy..) through API which is mentioned on previous step.
I wonder is there any alternative way to deploy node application(without created with StrongLoop tools) to StrongLoop host via web ui using some StrongLoop API?
I have looked API could not find specific solution.
What you require is a CDP (Continuous delivery pipeline) setup, there seem to be many ways in which you can achieve this (easiest way is using Codeship or similar platforms), but if you want to know how it works it requires a bit of orchestration tools to help you. To describe the steps I'll be using the following tools:
Docker (what is docker?)
Ansible (Use Cases and How it works?)
Jenkins (What is it and Why to use it?)
"There are many other combination of tools that you can look at, but this should give you an idea"
Now that we have the tools, I'll try to describe the deployment pipeline with a very basic use-case.
Step I "Ideally" - Creating a docker image for your nodejs application.
What generally everyone suggests is that you create a docker image of your application. Then save this image on docker-hub. How this will help you is that, now your nodejs application is contained inside a docker image which makes it independent of the Host and can be deployed anywhere you want.
To create this image all you need to do is create a Dockerfile, which is described in the in the link I've shared.
Step II "Ideally" - Creating an Ansible playbook to mimic the setup steps of your application.
Ansible playbooks are basically used to automate every manual process that you would need to do in order to setup-deploy-run your application. This decreases the need to run even trivial tasks like "slc build".
Step III "Ideally" - This is where we get to the UI stuff
By using Jenkins, you are given a UI which will help you configure tasks that can be combined with Github hooks and trigger the deployment as soon as you make a commit. This is explained in more details in the link shared.
So to summarize, This is what goes on at back to some extent, in order to automate the build and deployment of your application using UI. I hope this serves as a good starting point to achieve your requirements, and also in case you want skip these steps in the start, you could always go with Codeship or similar other tools to help you with the steps that you've mentioned.

How should I version control (with SVN, for instance) a crontab?

I would like to version control my server's configuration, in case something happens to my server.
I think crontab files themselves are not intended to be edited directly (only through crontab commands), so how would I go about versioning them? Should I version the files anyway? Is there something else I should be looking for?
I guess you're trying to automate something on a web application. It clearly goes beyond the simple fact of your server crashing. What if you want to add another front-end server for example ?
People in the ruby community came out with a pretty nice tool, "whenever" (https://github.com/javan/whenever) to solve this issue.
Namely, the proper way is not to version control the crontab. It's rather up to each app to be able to properly configure itself.
In the case of Rails applications for example, you would use a tool like Capistrano to automate your deployment. And one of the capistrano task would be to setup the correct cron jobs, thanks to whenvever. Hope this helps !

Gallio Integration with NANT and CruiseControl.NET

In our build process we're currently using MBUnit 2.x tests, called from an NAnt task, called from CruiseControl.NET. I've uprgaded to Gallio and MBUnit 3.x locally and am able to run tests from VS2008. I'm having trouble getting our build process upgraded. It looks like we have two options, either run the tests from CruiseControl.net or from NAnt. Based on this, I have two questions:
With all other things being equal, where should these tests be run, NAnt or CruiseControl.net, or does it really matter at all?
If you like doing this sort of thing in NAnt, do you have any documentation or examples of how to implement it? I've found documentation for the CC.NET soution in my Gallio\extra\CCNet directory in the Gallio installation.
Thanks
Your options for running tests as part of your build with Gallio are similar to what they were with MbUnit v2.
I recommend running the tests from your NAnt or MSBuild scripts using the provided tasks in Gallio.NAntTasks.dll and Gallio.MSBuildTasks.dll.
However, if you want to run the tests directly from the CCNet configuration, then you can add a CCNet task to execute the Gallio.Echo.exe program.
Here's a bit more info on the NAnt task that someone else blogged about. Some of the details have changed in recent releases but it should get you on the right track.
http://testdrivendevelopment.wordpress.com/2008/12/01/use-nant-to-run-mbunit-tests-using-gallio/

Resources