The following is the application delcaration json file
{
"apps" : [{
"name" : "test_v2",
"script" : "bin/www",
"log_date_format" : "YYYY-MM-DD HH:mm Z",
"ignore_watch" : ["[\\/\\\\]\\./", "node_modules"],
"watch" : true,
"node_args" : "--harmony",
"cwd" : "/root/src/test_v2",
"env": {
"NODE_ENV": "production",
"AWESOME_SERVICE_API_TOKEN": "xxx",
"TZ": "America/Los_Angeles"
}
}]
}
To change the time zone, i had followed as commented at https://github.com/Unitech/pm2/issues/560
But it does not work. The behavior is the same as thought the "TZ" is not present. I tried even hard coding the time zone to numeric value like "+08:00" which does not work. How to change the time zone in the logs.
log_date_format in directly used with momentjs in pm2 - source.
The following options are available in moment.
I don't think that timezone has been implemented in any way but you can remove Z and use the UTC time.
If you really need a timezone implementation, fire a feature issue on pm2.
From that same Github issue mentioned above, this helped me:
First update the format (make sure server timezone is what you want)
pm2 restart 0 --log-date-format "HH:mm:ss DD-MM-YYYY Z"
save all processes
pm2 save
run these
npm i -G pm2 //if not latest
pm2 update
Related
I have the following JSON file (song.json) that contains:
{
"Result": [
{
"ItemTitle": "Sometimes It Hurts",
"Artists": [
"Voost"
],
"MediaEnd": "00:02:15.8490000",
"Extro": "00:02:12.8200000",
"MediaId": 9551,
"ActualLength": "00:02:12.8200000",
"ItemType": "Song"
},
{
"ItemTitle": "Been a Long Time (Full Intention 2021 Remix)",
"Artists": [
"The Fog"
],
"MediaEnd": "00:03:11.3170000",
"IntroEnd": "00:00:07.4700000",
"Extro": "00:03:08.6300000",
"MediaId": 9489,
"ActualLength": "00:03:08.6300000",
"ItemType": "Song"
}
],
"ExceptionMessage": null,
"FailMessage": null,
"ExceptionTypeName": null
}
I want to extract the first “ItemTitle” and the first “Artist” and save them as variables.
In this example the result I am looking for would be:
ItemTitle=Sometimes It Hurts
Artist=Voost
I have been trying to use jq-win64.exe as this needs to run in a Windows Batch File, but I can’t get the syntax right. I have tried various examples that I have found on here but none of them appears to work as required. Can anyone suggest a solution?
First things first.
Since you seem to be having trouble on several fronts , I would suggest that you first get your jq query working the way you want
by using jq with the -f command-line option. That way, you can write your query without having to worry about
Windows rules for escaping characters on the command line. When the results are as you wish, you might even to decide to
leave well-enough alone.
Next, to obtain the values you want, it would seem you will want a jq query like this:
.Result | first(.[].ItemTitle), first(.[].Artists[])
With your JSON, this produces:
Sometimes It Hurts
Voost
But you say you want these values in the KEY=VALUE form. This can be achieved by modifying the basic query, e.g. as follows:
.Result|"ItemTitle=\(first(.[].ItemTitle))", "Artist=\(first(.[].Artists[]))"
Somehow I doubt this is really what you want, but the rest should be clear sailing.
I follow the basically solutions to solve it, but I already had the problem.
In my configure.ac file I have a check for mysql:
AC_CHECK_HEADER([mysql/mysql.h], ,AC_MSG_ERROR([Could not find mysql headers !]))
and of course it complain because, as explain here:
If the header files are installed in a nonstandard location, such as
/opt/include, and CPPFLAGS doesn't refer to that directory-for
example, as -I/opt/include-the AC_CHECK_HEADER macro will fail, even
though the files do exist on the system. However, this is an issue for
the system's administrator. Part of the convenience of autoconf is
that you, as the developer, don't need to worry about these details.
So, as developer, what's the way to go to solve it properly ?
I also put the path of real location in Makefile with -I/usr/include/mysql, but it continues to complain.
EDIT: as suggestd I post the configure.ac (the main parts):
useMysql=no
AC_MSG_CHECKING([whether to use mysql])
AC_ARG_ENABLE(mysql,
[ --enable-mysql Enable mysql support],
[MYSQL="$enableval"]
useMysql=yes,
[MYSQL="no"]
)
AC_MSG_RESULT([$MYSQL])
AC_SUBST([MYSQL])
[...]
if test "$MYSQL" = "yes"; then
AC_CHECKING([for MYSQL Library and Header files])
AC_CHECK_HEADER([mysql/mysql.h], ,AC_MSG_ERROR([Could not find mysql headers !]))
AC_CHECK_LIB(mysqlclient, mysql_init, [ MYSQL_LIBS="-lmysqlclient" ], [AC_MSG_ERROR([$PACKAGE_NAME requires but cannot find mysqlclient])])
AC_DEFINE(USE_MYSQL, 1, [Use MYSQL library])
AC_SUBST(MYSQL_LIBS)
fi
then I use the MYSQL_LIBS in the Makefile:
AM_CFLAGS = -g -fPIC -rdynamic -I$(top_srcdir)/include -I/usr/include/mysql
I use filebeat to write logs to an elasticsearch server. My logs are in json format. Every line is a json string that looks like this
{"#timestamp": "2017-04-11T07:52:480,230", "user_id": "1", "delay": 12}
I want the #timestamp field from my logs to replace the #timestamp field that filebeat creates when reading the logs. On my kibana dashboard I always get
json_error:#timestamp not overwritten (parse error on 2017-04-11T07:52:48,230)
and end up seeing the #timestamp field created by filebeat
My filebeat conf includes those lines regarding overwriting fields
json.keys_under_root: true
json.overwrite_keys: true
json.add_error_key: true
Also from my log4j conf the #timestamp field created in my logs is in ISO8601 format. Any idea what the problem is and why the #timestamp field is not overwritten?
The problem was the format of the timestamp that log4j is producing.
Filebeat expects something of the form "2017-04-11T09:38:33.365Z" it has to have to T in the middle the Z in the end and dot instead of comma before the milliseconds.
Quickest (and somewhat dirty) way I found to do that was by using the following pattern
pattern='{"#timestamp": "%d{YYYY-MM-dd}T%d{HH:mm:ss.SSS}Z"}
A similar issue can be found here. The suggested solution does not solve the filebeat issue though because it uses comma!
I have what seems to be like a valid use case for an unsupported - afaik - scenario, using packer.io and I'm worried I might be missing something...
So, in packer, I can add:
many builders,
have a different name per builder,
use the builder name in the only section of the provisioners and finally
run packer build -only=<builder_name> to effectively limit my build to only the provisioners combined with the specific builder.
This is all fine.
What I am now trying to do, is use the same base image to create 3 different builds (and resulting AMIs). Obviously, I could just copy-paste the same builder config 3 times and then use 3 different provisioners, linking each to the respective builder, using the only parameter.
This feels totally wasteful and very error prone though... It sounds like I should be able to use the same builder and just limit which provisioners are applied .. ?
Is my only solution to use 3 copy-pasted builders? Is there any better solution?
I had the same issue, where I want to build 2 different AMIs (one for staging, one for production) and the only difference between them is the ansible group to apply during the provisioning. Building off the answer by #Rickard ov Essen I wrote a bash script using jq to duplicate the builder section of the config.
Here's my packer.json file:
{
"builders": [
{
"type": "amazon-ebs",
"name": "staging",
"region": "ap-southeast-2",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"instance_type": "t2.nano",
"ssh_username": "ubuntu",
"force_deregister": true,
"force_delete_snapshot": true,
"ami_name": "my-ami-{{ build_name }}"
}
],
"provisioners": [
{
"type": "ansible",
"playbook_file": "provisioning/site.yml",
"groups": ["{{ build_name }}"]
}
]
}
The ansible provisioner user the variable build_name to choose which ansible group to run.
Then I have a bash script build.sh which runs the packer build:
#!/bin/bash
jq '.builders += [.builders[0] | .name = "production"]' packer.json > packer_temp.json
packer build packer_temp.json
rm packer_temp.json
You can see what the packer_temp.json file looks like on this jqplay.
If you need to add more AMIs you can just keep adding more jq filters:
jq '.builders += [.builders[0] | .name = "production"] | .builders += [.builders[0] | .name = "test"]
This will add another AMI for test.
only works on filters on builder name so that is not an option.
You could solve this with any of these aproches:
Preprocess a json and create 3 templates from one.
Use a template with a user variable defining which build it is and build 3 times. Use conditions on the variable in you scripts to run the correct scripts.
Build a base AMI with the common parts of the template and then run 3 different builds on that provisioning the differences.
In general Packer try to solve one thing well, by not including a advanced DSL for describing different build flavours the scope decreses. It's easy to preprocess and create json for more advanced use cases.
I want to use different flags (sourcemap, out, target) that the typescript compiler provides. I am trying to define a build system in sublime 2 but unable to do so.
Have already read this question.
basically i want to do something like the following
tsc src/main/ts/myModule.ts --out src/main/js/myModule.js --sourcemap --target ES5
Just add them to the cmd array
{
"cmd": ["tsc","$file", "--out", "src/main/js/myModule.js"],
"file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
"selector": "source.ts",
"osx": {
"path": "/usr/local/bin:/opt/local/bin"
}
}
First of all let me say that I'm using Sublime Text 3 on Windows and Typescript 1.0.
I don't think that SublimeText2 is so much different, though...
If you're on similar conditions, take a look at my current configuration file:
{
"cmd": ["tsc", "$file"],
"file_regex": "(.*\\.ts?)\\s*\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(.+?)$",
"selector": "source.ts",
"windows": {
"cmd": ["tsc.cmd", "$file", "--target", "ES5"]
}
}
Please notice that I tweaked the regex so that it matches the TSC error format (and brings you to the line containing the error when you double click it from the error log...)
Besides of that, I think that the real command-line which gets run is the lower one: as a matter of fact I had it working only placing the options down there... (in this specific case I'm asking an ES5 compilation type, your parameters will differ).
This suppose you have a tsc.cmd avaliable on path; if not, put the full path of tsc.cmd or tsc.exe instead of "tsc.cmd" and be sure to escape backslashes \ as \\...
This works in my situation, maybe in other contexts they should also be placed on the first line...
Hope this helps :)