I am currently starting multiple Node.js processes using pm2. These processes are defined in a JSON file, which is used by running
pm2 start pm2.json
As you can see from the JSON file below, there is a lot of repetition. For example, making a change to the error_file location or setting the variable time to true involves a lot of repetition, which can be tedious with 10-20 such scripts defined in the JSON file.
Is it possible to simplfy the JSON file by setting time variable only once in the file and have it apply to all processes?
Also, is it possible to use a template to define error_file and out_file, such as "../logs/${name}-error.log"?
Example pm2.json
{
"apps": [
{
"name": "foo-a",
"script": "./foo/a.js",
"args": "-e apple",
"error_file": "../logs/foo-a-error.log",
"out_file": "../logs/foo-a-out.log",
"time": true
},
{
"name": "foo-b",
"script": "./foo/b.js",
"args": "-e banana",
"error_file": "../logs/foo-b-error.log",
"out_file": "../logs/foo-b-out.log",
"time": true
}, {
"name": "bar-c",
"script": "./bar/c.js",
"args": "-e cranberry",
"error_file": "../logs/bar-c-error.log",
"out_file": "../logs/bar-c-out.log",
"time": true
},
...
You can use js file instead json file, it will allow you to create and use common variable/function for repetition part.
const time = true
module.exports = {
"apps": [
{
"name": "foo-a",
"script": "./foo/a.js",
"args": "-e apple",
"error_file": "../logs/foo-a-error.log",
"out_file": "../logs/foo-a-out.log",
"time": time
},
{
"name": "foo-b",
"script": "./foo/b.js",
"args": "-e banana",
"error_file": "../logs/foo-a-error.log",
"out_file": "../logs/foo-a-out.log",
"time": time
}, {
"name": "bar-c",
"script": "./bar/c.js",
"args": "-e cranberry",
"error_file": "../logs/bar-c-error.log",
"out_file": "../logs/bar-c-out.log",
"time": time
},
...
Related
We are using Cytoscape + neo4j + spring boot + REST. We've tried to use some formats pass to frontend, however didn't work that well. So looking for best structure to use Cytoscape js.
========
Added later.
For example response from neo4j apoc export json query would be like this:
{
"application": {
"type": "node",
"id": "hhj354",
"labels": [
"Application"
],
"properties": {
"appid": "A90378",
"name": "hkjgj",
"status": "In Production"
}
},
"changes": [
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": sfd
},
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": sfd
},
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": 453
}
]
}
I need some detailed parsing codes. Parsing in backend or front end both ok as long as short enough.
Thanks in advance.
As far as I'm concerned, the front-end should do the less calculations as possible.
Therefore, try to send a JSON as close as possible to the format specified in the specs of cytoscape.js
The basic idea of graph is that it's composed of nodes and edges, those elements (as cytoscape calls them) have ids that can help you select them in a easier way.
No Calculation in Back-End
If you want to use built-in format .json from CALL apoc.export.json.all("all.json",{useTypes:true})then you will have for example to do some transformation in the front-end:
responseJson => {
responseJson.map(element => {
return {
group: element.type,
data : {
id: `${element.type}${element.id}`,
myFavouriteProperty: element.property
}
}
}
In my Blockly project, I have two 3 blocks rcm_a, rcm_b and rcm_c.
Blockly.defineBlocksWithJsonArray([{
"type": "rcm_c",
"message0": "Requirement block- rcm_a: %1 rcm_b: %2",
"args0": [
{
"type": "input_value",
"name": "rcm_a"
},
{
"type": "input_value",
"name": "rcm_b",
"check": ["rcm_b"]
}
],
"output": "Text",
"colour": "%{BKY_LOOPS_HUE}"
}]);
As you can see the above code of rcm_c, I am trying to restrict the second input to be of block rcm_b, and that apparently doesn't seem to be working. The same input will not accept any input type. Here's rcm_b's code:
Blockly.defineBlocksWithJsonArray([{
"type": "rcm_b",
"message0": "rcm_b %1",
"args0": [
{
"type": "input_value",
"name": "VALUE1",
"check": "String"
}
],
"output": "Text",
"colour": "%{BKY_LOOPS_HUE}"
}]);
I tried following this guide's Statement Stacks section (I am aware that I am trying to type check inputs and not statements) to achieve type-checking. What am I doing wrong?
Help is much appreciated!
Ah, seems like the 'output' of rcm_b needed to be rcm_b!
I use Nightwatch-Cucumber to automate my end2end tests and want to create a cucumber html report after test execution with cucumber-html-reporter, but I get an error while report generation by cucumber-html-reporter:
Unable to parse cucumberjs output into json: 'reports/cucumber.json' SyntaxError: reports/cucumber.json: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.readFileSync (/Users/GRme/projects/e2e-web-tests/node_modules/jsonfile/index.js:69:17)
And I don't know why my generated cucumber.json is invalid.
I use the following versions:
"cucumber-html-reporter": "^2.0.0",
"nightwatch": "^0.9.16",
"nightwatch-cucumber": "^7.1.10",
This is my config in nightwatch.conf.js:
require('nightwatch-cucumber')({
cucumberArgs: [
'--tags', '#run',
'--require', 'timeout.js',
'--require', 'hooks.js',
'--require', 'features/step_definitions',
'--format', 'pretty',
'--format', 'json:reports/cucumber.json',
'features']
});
And this is the hooks.js, where my cucumber html report generation is executed:
const {client} = require('nightwatch-cucumber');
const {defineSupportCode} = require('cucumber');
var reporter = require('cucumber-html-reporter');
var options = {
theme: 'bootstrap',
jsonFile: 'reports/cucumber.json',
output: 'reports/cucumber_report.html',
reportSuiteAsScenarios: true,
launchReport: false,
//ignoreBadJsonFile: true,
name: 'NIKITA end2end tests',
brandTitle: 'NIKITA end2end tests',
storeScreenShots: true,
metadata: {
// "App Version": "0.0.1",
// "Test Environment": "AAT",
// "Browser": "Chrome XXX",
// "Platform": "Mac OS X",
}
};
defineSupportCode(({Before, After}) => {
Before(function() {
client.maximizeWindow();
});
After(function() {
reporter.generate(options);
});
});
My generated and apparently invalid cucumber.json looks like this:
[
{
"keyword": "Feature",
"line": 1,
"name": "only a test feature",
"tags": [],
"uri": "/Users/GRme/projects/e2e-web-tests/features/testFeature.feature",
"elements": [
{
"keyword": "Scenario",
"line": 4,
"name": "only a test Scenario",
"tags": [
{
"line": 3,
"name": "#run"
}
],
"id": "only-a-test-feature;only-a-test-scenario",
"steps": [
{
"arguments": [],
"keyword": "Before",
"result": {
"status": "passed",
"duration": 1
},
"hidden": true,
"match": {
"location": "/Users/GRme/projects/e2e-web-tests/hooks.js:24"
}
},
{
"arguments": [],
"keyword": "When ",
"name": "\"1\" seconds waiting",
"result": {
"status": "passed",
"duration": 2615
},
"line": 5,
"match": {
"location": "/Users/GRme/projects/e2e-web-tests/features/step_definitions/abstractStepDefinition.js:10"
}
},
{
"arguments": [],
"keyword": "After",
"result": {
"status": "passed",
"duration": 4
},
"hidden": true,
"match": {
"location": "/Users/GRme/projects/e2e-web-tests/hooks.js:28"
}
}
]
}
],
"id": "only-a-test-feature"
}
]
Generating the Cucumber Html Report via Jenkins with the Cucumber Reports Plugin runs successful.
So, how can I solve my problem and which framework (Nightwatch-Cucumber or cucumber-html-reporter) is the reason? And what is the invalid part of my generated cucumber.json?
Try to generate cucumber html report in a separate step of test execution. For example if you are using npm script use a separate npm script to generate the report. The problem with your approach is that in Cucumber.js global After hook the report is not created yet. That's why you are getting such an error. I suggest to use a separate node.js script to run cucumber-html-reporter.
I solved the problem by using Event Handler. I put the Cucumber report generation in such a Event Handler function for the event AfterFeatures and it works perfect for me.
More information you can find here.
I'm working in Visual Studio Code in Ubuntu on my Typescript project. And I'm wondering is there any possibility to execute some kind of 'clean' task.
Here's my tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"tasks": [
{
"taskName": "tsc",
"command": "tsc",
"isShellCommand": true,
"isBackground": true,
"problemMatcher": "$tsc"
},
{
"taskName": "clean",
"linux": {
"command": "rm",
"args": [
"./src/*.js"
],
"isShellCommand": true
},
"isShellCommand": true,
"isBackground": true
}
]
}
And here's my project structure.
Executing task clean says there's no such files or directory, while executing 'pwd' instead of rm says that I'm in the root of my project.
Any suggestions how does this build system work? Maybe there's some special syntax for env variables in VS Code?
After VSCode 1.14, we have a new tasks manager in VSCode. I'm using .NET Core on ubuntu and I have a build and a clean tasks like this:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "process",
"command": "dotnet",
"args": [
"build",
"MyProj.csproj"
],
"options": {
"cwd": "${workspaceFolder}/src/MyProj/"
},
"problemMatcher": "$msCompile"
},
{
"label": "clean",
"type": "shell",
"linux": {
"command": "rm",
"args": [
"-rfv",
"bin/*",
"obj/*"
]
},
"windows": {
"command": "del",
"args": [
"/S /Q",
"bin/*",
"obj/*"
]
},
"options": {
"cwd": "${workspaceFolder}/src/MyProj/"
},
"problemMatcher": []
}
]
}
Both tasks works as expected.
I have also been looking for this, but as far as I understand, it's not possible to have more than one task in tasks.json. You can have a tasks array, but that only contains different command line parameters for the same task. This example has the 'echo' task, and you can call it with different parameters. If you call the task 'hello' then 'echo Hello World' will be executed:
{
"version": "0.1.0",
"command": "echo",
"isShellCommand": true,
"args": [],
"showOutput": "always",
"echoCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "hello",
"args": ["Hello World"]
},
{
"taskName": "bye",
"args": ["Good Bye"]
}
]
}
Have you tried using workspace variables? ${workspaceRoot} might be particular useful for you.
Save your data in the repository at VisualSVN
https://myserver.ru:8443/svn/my-repository/my-project
Can I get the current version of the project in SVN using php or javascript (javascript (jQuery, Ajax etc) is preferable)?
As you mention php I thought that you may also use js on the server (node). If this is the case, this module can help:
https://github.com/ddliu/node-svn-spawn
This is a sample response from a getstatus command:
[
{
"$": {
"path": "a.txt"
},
"wc-status": {
"$": {
"props": "none",
"item": "modified",
"revision": "1"
},
"commit": {
"$": {
"revision": "1"
},
"author": "dong",
"date": "2013-11-08T02:17:20.390152Z"
}
}
}
]