I have pm2 running my node app, and was wondering if I can make sure it is reloading with zero downtime on the watch, rather than just restarting. Here is a sample json file that is setup how I am using pm2.
{
"name" : "server",
"cwd" : "/home/user/website",
"script" : "server/server.js",
"instances" : 2,
"max_restarts" : 0,
"watch" : true,
"ignore_watch" : ["some/files"],
"env_staging": {
"NODE_ENV": "staging"
},
"env_production": {
"NODE_ENV": "production"
}
}
nope, got the same problem, according to the documentation and source code, this is not possible
Related
I am trying to setup Nightwatch so that I do not have to use Selenium and instead point directly to an instance of Chrome on Linux, but I seem to be unable to connect to the chromedriver instance.
nightwatch.json
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "globals.js",
"selenium" : {
"start_process" : false,
"cli_args" : {
"webdriver.chrome.driver" : "./chromedriver"
}
},
"test_settings" : {
"default" : {
"selenium_port" : 9515,
"selenium_host" : "127.0.0.1",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "chrome",
"acceptSslCerts": true
}
}
}
}
After attempting to run a simple test suite, I get the following error
~/scripts/TestNightwatch$ nightwatch
[Test] Test Suite
=====================
Running: Demo test Google Error processing the server response:
unknown command: wd/hub/session
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started? { value: -1, error:
'Unexpected token u in JSON at position 0' }
Have I not configured nightwatch properly to connect to Chrome? Am I missing any pieces of the puzzle?
Thanks in advance!
globals.js
var chromedriver = require('chromedriver');
module.exports = {
before : function(done) {
chromedriver.start();
done();
},
after : function(done) {
chromedriver.stop();
done();
}
}
The issue may be that Chromedriver is expecting commands at / instead of /wd/hub. To fix, start Chromedriver with --url-base=/wd/hub
Source: Selenium WebDriverJS, cannot build webdriver for Chrome and https://github.com/webdriverio/webdriverio/issues/113
You need to start chromedriver in your external globals file. It looks like your config is correct. Just setup your before and after functions in the external globals module to start chromedriver.
before : function(done) {
chromedriver.start();
done();
},
after : function(done) {
chromedriver.stop();
done();
}
Take a look at the Getting Started guide for more details.
I recently migrated my Ionic app into Ionic Cloud and after running ionic io init in the command-line, I noticed that I end up with two (config?) json files that seem to have the same purpose. However they have different names and I am not sure which one should be kept. The contents are as follows:
.io-config.json
{
"app_id": "id",
"api_key": "key"
}
ionic.config.json
{
"name": "name",
"app_id": "id",
"watchPatterns": [
"www/**/*",
"!www/lib/**/*"
]
}
Which one should be kept?
According to an expert on Ionic's Slack, both files should be kept. They each have their own specific purpose.
I'm using:
Elasticsearch 2.3
Watcher
Topbeat
The goal is to create a watch that every x amount of time does a query and retrieves some hits, and post it to a web server. This works fine. However, the Json response in {{ctx.payload.hits.hits}} isn't Json, so I can't proccess it. The same issue seems to appear in some threads, this being the most similar to mine:
So, this is my watch (the input works fine, the issue is in the script of the action):
PUT _watcher/watch/running_process_watch
{
"trigger" : {
"schedule" : {
"interval" : "10s"
}
},
"input" : {... },
"actions" : {
"ping_webhook": {
"transform":{
"script": "return [ body: groovy.json.JsonOutput.toJson(ctx.payload.hits.hits)]"
},
"webhook": {
"method": "POST",
"host": "localhost",
"port": 4567,
"path": "/register_data",
"headers": {
"Content-Type" : "application/json"
},
"body" : "data: {{ctx.payload.body}}"
}
}
}
}
The error:
failed to execute [script] transform for [running_process_watch_0-2016-06-08T17:25:14.162Z]
ScriptException[failed to run inline script [return [ body: groovy.json.JsonOutput.toJson(ctx.payload.hits.hits)]] using lang [groovy]]; nested: MissingPropertyException[No such property: groovy for class: 1605d064acb49c10c464b655dacc9193f4e2e484];
at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:320)
at org.elasticsearch.watcher.transform.script.ExecutableScriptTransform.doExecute(ExecutableScriptTransform.java:74)
at org.elasticsearch.watcher.transform.script.ExecutableScriptTransform.execute(ExecutableScriptTransform.java:60)
at org.elasticsearch.watcher.transform.script.ExecutableScriptTransform.execute(ExecutableScriptTransform.java:41)
at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:94)
at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:388)
at org.elasticsearch.watcher.execution.ExecutionService.execute(ExecutionService.java:273)
at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:438)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Any idea to make groovy.json usable inside the watcher action script? Or any other idea to return proper json from the ctx.hits.hits?
So, I opened an issue in Elasticsearch repo. After some discussion, a native toJson function is going to be implemented in the mustache templating engine so it renders json by default.
Here is the pull request.
Hopefully in the next release will be ready.
I've been developing an app for about a year now, so I started it mid-2014 and have been upgrading ember.js and ember-cli as things move forward on those projects. I'm at Ember 1.11 now.
EDIT: Application Adapter
var ApplicationAdapter = DS.RESTAdapter.extend( {
namespace: 'api',
host: null,
setHost: Ember.on('init', function() {
set(this, 'host', this.container._registry.resolve('config:environment').API_ENDPOINT);
})
});
export default ApplicationAdapter;
My JSON API returns a main projects object, along with other sideloaded objects (like projectStatus). What I can't understand is, since I don't have any adapters or serializers that specify this, how I'm it's able to use the returned JSON, because it looks like this:
{
"projects" : {
"id": 4462875
"projectName" : "New business from Acme",
"projectDescription" : "Just another great project",
"pmlinks" : [ 1, 2],
"statusLinks" : [ 1440 ],
"commentsLinks" : [ 39 ]
},
"projectResources" : [ {
"id" : 1,
"name" : "Wile E. Coyote"
}, {
"id" : 2,
"name" : "Roadrunner"
}],
"projectComments" : [ {
"id" : 39,
"projectComment" : "started the project",
} ],
"projectStatuses" : [ {
"id" : 1440,
"status" : "G",
"trending" : "N",
"comment" : null,
"lastModifiedDate" : "2015-07-17T13:46:11.037+0000",
"project" : 4462875
} ],
}
I can't find anything in the Ember docs that recommend this "*Links" format for the relationships, and in fact it suggests using something more like status_ids. But the example it shows doesn't use _ids so I'm even more confused.
Here's a snippet of my project model:
statusUpdates: DS.hasMany('projectStatus'),
projectComments: DS.hasMany('projectComment'),
projectResources: DS.hasMany('projectResource'),
What I'm trying to figure out is with my new belongsTo relationship to schedule, how should the JSON be formatted from the API? It seems to work if the project object has a property like this "scheduleLinks": [10] but not if it's like "schedule": 10 or "schedule_id": 10 and that seems to be what the documentation says should work.
EDIT:
Maybe it's because the other objects like projectComments are named the way my model expects, and they're all returned at the same time from one API, that it doesn't even matter what the properties in the projects object is? Is that only to look up relationships if they're not all sideloaded?
The sideloading definitely is the thing here. Because if I change "statusLinks" to "projectStatus" then, since I have that relationship established in the project model, it will try to hit the API for that, e.g. /api/projectstatuses/:id.
So what seems to be happening is that the relationship is being hooked up from the belongsTo side implicitly; if the data is sideloaded, I don't need any links or IDs on the main object.
I have a file where each line is a JSON object (actually, it's a dump of stackoverflow). I would like to load this into Apache Pig as easily as possible, but I am having trouble figuring out how I can tell Pig what the input format is. Here's an example of an entry,
{
"_id" : { "$oid" : "506492073401d91fa7fdffbe" },
"Body" : "....",
"ViewCount" : 7351,
"LastEditorDisplayName" : "Rich B",
"Title" : ".....",
"LastEditorUserId" : 140328,
"LastActivityDate" : { "$date" : 1314819738077 },
"LastEditDate" : { "$date" : 1313882544213 },
"AnswerCount" : 12, "CommentCount" : 19,
"AcceptedAnswerId" : 7,
"Score" : 83,
"PostTypeId" : "question",
"OwnerUserId" : 8,
"Tags" : [ "c#", "winforms" ],
"CreationDate" : { "$date" : 1217540572667 },
"FavoriteCount" : 13, "Id" : 4,
"ForumName" : "stackoverflow.com"
}
Is there a way I can load a file where each line is one of the above into Pig without having to specify the schema by hand? Or perhaps a way to automatically generate a schema based on the (possibly nested) keys observed in all objects? If I do need to specify the schema by hand, what would the schema string look like?
Thanks!
The quick and easy way: use Twitter's elephantbird project. Inside is a loader called com.twitter.elephantbird.pig.load.JsonLoader. When used directly like so,
A = LOAD '/path/to/data.json' USING com.twitter.elephantbird.pig.load.JsonLoader() as (json:map[]);
B = FOREACH A GENERATE json#'fieldName' AS field_name;
nested elements won't be loaded. However, you can easily fix that (if desired) by changing it to,
A = LOAD '/path/to/data.json' USING com.twitter.elephantbird.pig.load.JsonLoader('-nestedLoad')
Including elephantbird is easy -- simply pull the the project "elephant-bird" with organization "com.twitter.elephantbird" using Maven (or equivalent's) dependency manager, then issuing the usual register command in pig
register 'lib/elephantbird.jar';