pm2-logrotate install on offline linux machine - pm2

I want to install pm2-logrotate on linux machine where the machine is not having internet connectivity
https://www.npmjs.com/package/pm2-logrotate

To make an offline installer, you need to make your own tar.gz file.
First, you need to download the Source code (tar.gz) from Pm2 GitHub
Extract the tar.gz file and this will create a folder with the source inside
Rename the main folder (normally named pm2-logrotate-2.7.0) to module and create the pm2-logrotate-2.7.0.tar.gz file again with the module folder
The struct of the files inside of the tar.gz will be something like:
module
|- .gitignore
|- CHANGELOG.md
|- README.md
|- app.js
|- node_modules
|- package-lock.json
|- package.json
|- pres
|- test
Then you can use the command pm2 install pm2-logrotate-2.7.0.tar.gz without getting errors

1.Download source code tar.gz pm2-logrotate
2.Install modules in code, Copy code to the same server environment(in network)
tar -xzvf pm2-logrotate-2.7.0.tar.gz
cd pm2-logrotate-2.7.0/
npm install
tar -czvf pm2-logrotate.tar.gz pm2-logrotate-2.7.0
3.Copy pm2-logrotate.tar.gz to offline server to .pm2/modules
cd ~/.pm2/modules/
tar -xzvf pm2-logrotate.tar.gz
pm2 module:generate pm2-logrotate
cd pm2-logrotate
pm2 install .
4.Add conf in to .pm2/module_conf.json
{
"pm2-logrotate": {
"max_size": "10M",
"retain": "30",
"compress": false,
"dateFormat": "YYYY-MM-DD_HH-mm-ss",
"workerInterval": "30",
"rotateInterval": "0 0 * * *",
"rotateModule": true
},
"module-db-v2": {
"pm2-logrotate": {}
}
}
Run pm2 conf pm2-logrotate can see pm2-logrotate config
Reset conf
pm2 set pm2-logrotate:max_size 100M

pm2 install pm2-logrotate-2.7.0.tgz

Related

podman machine init fails with unhelpful output

I am running the command
podman machine init
in the /entrypoint.sh script which I reference in my Dockerfile:
# Container image that runs your code
FROM ubuntu:latest
# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh
RUN apt-get update -y
RUN apt-get install -y git gcc python3-dev musl-dev libffi-dev podman
# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
The Dockerfile and the entrypoint.sh scripts are in my github repo where I have github actions configured. The problem I see my my log output from the Github action is this ...
2022-11-29T04:56:58.6855699Z + podman machine init
2022-11-29T04:56:59.1867174Z Downloading VM image: fedora-coreos-37.20221106.2.1-qemu.x8…
2022-11-29T04:56:59.3660034Z [1A[JDownloading VM image: fedora-coreos-37.20221106.2.1-qemu.x8…
...
2022-11-29T04:57:06.5082410Z [1A[JDownloading VM image: fedora-coreos-37.20221106.2.1-qemu.x8…
2022-11-29T04:57:06.9133659Z Extracting compressed file
2022-11-29T04:57:36.0586753Z Error: exit status 1
Extracting compressed file? Did I run out of disk space? What? I am not even sure where to begin to debug this.

COPY package.json - Dockerfile

I did a Dockerfile to a project in Node.js but an error happened.
Here's the Dockerfile:
FROM node:latest
RUN npm install nodemon -g
WORKDIR ./app
COPY package.json ./app
RUN npm install -g
COPY server.js ./app
EXPOSE 3000
CMD ["npm", "start"]
When I tried building this Dockerfile happen an error like this:
Step 4/8 : COPY package.json ./app
COPY failed: stat /var/lib/docker/tmp/docker-builderXXXXXXXX/package.json: no such file or directory
How can I fix it?
Docker version 17.12.0
Do not ever run nodemon in production (if that's what you tried to do).
You should configure your restart in case if app crashes. Preferably, set it to always in docker-compose.yml
The best way to structure Dockerfile in your case:
FROM node:latest
WORKDIR ./app
# please note, you already declared a WORKDIR,
# therefore your files will be automaticaly pushed to ./app
COPY package.json ./
RUN npm install -g
COPY ./ ./
EXPOSE 3000
CMD ["npm", "start"]
Hope, that helps.
Make sure you have package.json and server.js files in the same directory of your Dockerfile and it should work.
When you build a docker image, the whole content of the directory becomes your docker build context, and docker will find the files you COPY or ADD from there.
You might sometime wants to prevent some of those files to be sent to the build context, in which case you use the .dockerignore file to specify those files. Good luck!
My suggestion, move all files to the WORKDIR than execute your npm install
FROM node:latest
RUN npm install nodemon -g
WORKDIR /app
ADD . /app
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]

PM2 doesn't watch file change at Vagrant machine

I set up a server with the following directory structure:
project
|-- bootstrap
| `-- process.json
`-- server
|-- server.js
`-- other_folder
The project/bootstrap/process.json is the PM2 app config file and the project/server/server.js is the server entry. I define the process.json as
{
"apps": [
{
"name": "odd.server",
"script": "../server/server.js",
"watch": "../server"
}
]
}
I try to start the server and watch any change in the server with the following command:
pm2 start process.json --only odd.server --env production
The server is up, however, the file watching is not working. Any change made to the server.js cannot trigger the restart of the server.
The path is correct and I have no idea on why it doesn't work. I will be grateful to anyone who provides some hint.
UPDATE:
PM2 is running in a Vagrant machine and the project folder is a folder of my host machine that is exposed to Vagrant.
It needs to set the watch_options as
"watch_options": {
"usePolling": true
}
source: https://github.com/Unitech/pm2/issues/931

How to run an action hook on Red Hat OpenShift?

I read the documentation about Action Hook Scripts for OpenShift and created a pre_build action hook with the following commands on my OpenShift gear:
rhc ssh jbosswildfly
cd $OPENSHIFT_REPO_DIR/.openshift/action_hooks
touch pre_build
chmod a+x pre_build
Afterwards I created the pre_build file in the Git repository of my OpenShift application and pushed it to the repo. My deployments to OpenShift are performed by Travis CI and I got the following response:
remote: NOTE: The .openshift/action_hooks/pre_build hook is not executable, to make it executable:
remote: On Windows run: git update-index --chmod=+x .openshift/action_hooks/pre_build
remote: On Linux/OSX run: chmod +x .openshift/action_hooks/pre_build
So I executed git update-index --chmod=+x .openshift/action_hooks/pre_build (because I am running on Windows) and pushed that pre_build file again to my remote Git repository.
Now I get the following message:
remote: No such file or directory - /var/lib/openshift/54e8f8984382ecc9a1000047/app-root/runtime/repo/.openshift/action_hooks/pre_build
Why does it tell me now that it cannot find the pre_build file? If I login (via SSH) to my OpenShift gear, then it's there:
This is my pre_build file:
#!/bin/bash
echo Hello World

Cygnus installation

I try to install cygnus. I install yum install java-1.6.0-openjdk-devel and run , my problem is:
Then, the developed classes must be packaged in a Java jar file which must be added to the APACHE_FLUME_HOME/lib directory:
$ git clone https://github.com/telefonicaid/fiware-connectors.git
$ git checkout release/0.1
$ cd fiware-connectors/flume
$ APACHE_MAVEN_HOME/bin/mvn package
$ cp target/cosmos-injector-1.0-SNAPSHOT.jar APACHE_FLUME_HOME/lib
in this step, I create cygnus.jar not cosmos-injector-1.0-SNAPSHOT.jar , and # APACHE_FLUME_HOME/conf/cosmos-injector.conf not exist on my flume directory.
Alejandro, I recommend you to install last version of Cygnus (currenty, 0.7.1), which can be installed through RPM packages (recommended). Simply configure the FIWARE repo and install it using yum (CentOS):
$ sudo cat > /etc/yum.repos.d/fiware.repo <<EOL [Fiware]
name=FIWARE
repository baseurl=http://repositories.testbed.fi-ware.eu/repo/rpm/x86_64/
gpgcheck=0
enabled=1
EOL
$ yum install cygnus
You can find the Cygnus Quick Start Guide at this link.
The README will give you extended information about the tool.
Advanced topics can be found at the doc/ folder.