Closed yogithesymbian closed 2 years ago
solved as usually i always manual make a service systemd to run nodejs but now its error come when i tried with pm2 for instant deployment. but i using an ecosystem.config.js thats override my env but a little confused because i use .env with the ecosystem. before its run normaly using by .env file but now i just solved by :
put .env.production into ecosystem.config.js because i have some value
APP_URL:'https://api.domain.com/', // these point to my logo on qrcode
dunno why before its normal run but i have a lot of debug and founded some process.env is undefined so its auto change into localhost.
here is my full ecosystem.config.js instead of .env or .env.production
module.exports = {
apps: [{
name: 'API-X',
script: '/var/www/api/server.js',
env: {
NODE_ENV: 'production',
},
env_production: {
NODE_ENV:"production", // before i only have these value, i thinks its make ,env.production running in expected and bellow just from .env.production make its work
NODE_LOCAL_HTTPS:"false",
APP_URL:'https://api.domain.com/', // these pointing for load avatar png on save image qrcode
NODE_MAIL:"email@gmail.com",
NODE_MAIL_PASS:"password",
APIKEY:"",
DEV_DB_USERNAME:"x",
DEV_DB_PASSWORD:"",
DEV_DB_NAME:"x",
DEV_DB_HOSTNAME:"101.xx.x.xxx",,
DEV_DB_PORT:"3306",
CI_DB_USERNAME:"",
CI_DB_PASSWORD:"",
CI_DB_NAME:"",
PROD_DB_USERNAME:"x",
PROD_DB_PASSWORD:"x",
PROD_DB_NAME:"x",
PROD_DB_HOSTNAME:"101.xx.x.xxx",
PROD_DB_PORT:"3306",
PUSHER_APP_ID:"x",
PUSHER_KEY:"x",
PUSHER_SECRET:"x",
PUSHER_CLUSTER:"x",
PUSHER_CHANNEL_1:"x",
PUSHER_EVENT_LAND:"x",
},
watch: 'false',
ignore_watch: ['*.log'],
}],
deploy: {
production: {
user: 'root',
host: 'https://api.domain.com',
ref: 'origin/master',
repo: 'https://github.com/yogithesymbian/api-x.git',
path: '/var/www/api',
'pre-deploy-local': '',
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production',
'pre-setup': '',
},
},
}
i have pointing my subdomain with certbot to my nodejs with pm2 http://101.x.x.xxx to my api.mydomain.com i am using apache server.
here is the error from
pm2 logs --lines 100
did u have solution or tips to ignore the error ? my qrcode cant be created just cause the ssl .
FYI / by the way i work with firebase fcm where need https and its work like a charm but for the qrcode save its show an error.
when i tried with
NODE_TLS_REJECT_UNAUTHORIZED: 0
the news error come with warning and error 404 on catch from saveImage