I'm trying to wrap around pm2:
pm2.start(
{
apps: [
{
script: 'app.js',
path: 'remote/path',
name: 'App',
autorestart: false,
host: [123.456.789],
username: 'root',
},
],
},
err => {
if (err) throw err
},
)
It still seems to be trying to run app.js on my local machine, and not the host 123.456.789 - any idea what's going on?
host should be an array of strings: host: ['123.456.789'].
Related
I have hosted a Web app in Azure DevOps, the application built with Vue and Nuxt.
#vue/cli 5.0.1 and "nuxt": "^2.15.8". After hosting the web application works fine, I can login, then it navigates me to the listing page. But from there when I refresh the page it's showing this error. Sorry, check with the site admin for error: EISDIR .. in the browser and throwing a 500 Error in the console. In my login response I get only access token, there is no refresh token, could that be an issue? or any other settings in the Azure side? We tried setting this in the azure pm2 serve /home/site/wwwroot --no-daemon --spa. Still it's not working. Everything works fine in my dev environment.
export default {
ssr: false,
head: {
title: 'BBG Returns Self Service',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
plugins: ['~/plugins/clearTokens.js'],
components: true,
buildModules: ['#nuxtjs/style-resources'],
env: {
BASE_URL: 'https://my-api-url',
},
publicRuntimeConfig: {
baseURL: process.env.BASE_URL,
},
router: {
mode: 'history',
},
styleResources: {
// scss: ["~assets/scss/main.scss"],
},
modules: ['#nuxtjs/i18n'],
build: { transpile: [/^#storefront-ui/] },
server: {
port: 4200,
},
i18n: {
locales: [
{
code: 'en',
iso: 'en-GB',
name: 'English',
file: 'en.json',
icon: 'uk.svg',
},
{
code: 'de',
iso: 'de-DE',
name: 'Deutsch',
file: 'de.json',
icon: 'de.svg',
},
],
lazy: true,
langDir: 'i18n/',
defaultLocale: 'en',
detectBrowserLanguage: false,
},
target: 'static',
}
If deploying an SPA app, you need to have both:
target: 'static' (the default being 'server')
ssr: false
This removes quite some benefits regarding SEO + performance but at least, you still get all the benefits of the Nuxt DX and ecosystem.
To host it on Azure, you have several approaches, if you're using:
a static app, you can follow this official documentation for Azure Static Web Apps: https://nuxtjs.org/deployments/azure-static-web-apps/
a SSR app, you can follow this one about Azure Portal: https://nuxtjs.org/deployments/azure-portal
The actual issue was the Azure configuration. The resource should be created as Static website, then it will work fine.
Please follow this official documentation to understand How to Deploy in Azure.
https://nuxtjs.org/deployments/azure-static-web-apps/
A strapi API app connects and works perfectly on SQLlite. however we need it to connect to SQL Express db. the msssql module is installed through npm i mssql and the connection strings have been amended in order to connect to mssql heres the config file
/*
const fs = require( "fs" );
module.exports = ( { env } ) => ( {
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'sqlite',
filename: env( 'DATABASE_FILENAME', '.tmp/data.db' ),
},
options: {
useNullAsDefault: true,
},
},
},
} );
*/
const sql = require('mssql')
module.exports = ( { env } ) => ( {
defaultConnection: 'default',
connections: {
default: {
connector: 'mssql',
settings: {
user: "***",//process.env.DB_USER,
password: "***",//process.env.DB_PWD,
database: "***",//process.env.DB_NAME,
server: "**.**.**.**",
port: 1433,
connectionTimeOut: 150000,
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
},
options: {
enableArithAbort: true,
encrypt: false,
trustedConnection: true
},
useNullAsDefault: true
}
}
}
})
the command lines commended out (for the code above) is the previous connection to sql lite that works.
now the error message is the following:
PS C:*Team\Q*_Team\AngularAPI\ui\molla-angular\strapi> npm start
mollastrapi#0.1.0 start
strapi start
[2022-07-29T08:05:53.028Z] debug ⛔️ Server wasn't able to start properly.
[2022-07-29T08:05:53.029Z] error TypeError: requireConnector(...) is not a function
at Object.load (C:\****Team\Q****_Team\AngularAPI\ui\molla-
angular\strapi\node_modules\strapi-database\lib\connector-registry.js:20:65)
at DatabaseManager.initialize (C:\****Team\Q****_Team\AngularAPI\ui\molla-
angular\strapi\node_modules\strapi-database\lib\database-manager.js:32:21)
at Strapi.load (C:\****Team\Q****_Team\AngularAPI\ui\molla-
angular\strapi\node_modules\strapi\lib\Strapi.js:297:19)
at async Strapi.start (C:\****Team\Q***_Team\AngularAPI\ui\molla-
angular\strapi\node_modules\strapi\lib\Strapi.js:156:9)
PS C:\****Team\Q****_Team\AngularAPI\ui\molla-angular\strapi>
I am trying to get hmr working with vite in my craftcms site, whatever i try i keep getting
vite:hmr [no modules matched] src/scripts/main.ts +0ms
when i run vite in debug mode (vite --debug)
This is my vite config:
import ViteRestart from 'vite-plugin-restart'
export default ({ command }) => ({
base: command === 'serve' ? '' : '/dist/',
publicDir: 'non-existent-path',
build: {
manifest: true,
outDir: './web/dist/',
rollupOptions: {
input: {
app: './src/scripts/main.ts',
},
},
},
server: {
host: '0.0.0.0',
port: 3000,
strictPort: true,
https: true,
hmr: {
host: 'localhost',
port: 3000,
path: '/',
}
},
plugins: [
ViteRestart({
reload: ['templates/**/*'],
}),
],
})
Where am i going wrong?
I'm following a tutorial on youtube that uses node express knex and sqlite locally and postgres on heroku. I managed to get everything working locally with sqlite and have managed to load the app on heroku. I get the initial home message. I manged to create a blank postgres database on heroku and can look at the database credentials on heroku. I need to migrate my knex tables to the heroku postgres database. According to the video below I need to use this instruction
heroku run knex migrate:latest -a node-knex1
Which gives me the following error
Running knex migrate:latest on ⬢ node-knex1... up, run.3492 (Free)
Using environment: production
error: no pg_hba.conf entry for host "54.76.162.141", user "vnujkqszmxsboi", database "def52ulvb1tjg9", SSL off
at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:10:42)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
my knexfile.js looks like the following.
module.exports = {
development: {
client: 'sqlite3',
connection: {
filename: './data/lessons.db3',
},
useNullAsDefault: true,
pool: {
afterCreate: (conn, done) => {
conn.run('PRAGMA foreign_keys = ON', done);
},
},
},
production: {
client: 'pg',
connection: process.env.DATABASE_URL,
pool: {
min: 2,
max: 10,
},
migrations: {
tablename: 'knex-migrations',
directory: './migrations',
},
},
};
[Node Express Tutorial 18 - Setting up a Postgres database in
Heroku][1]
[1]: https://www.youtube.com/watch?v=OZQWfW3VvhE&list=PLKii3VqdFnoZY6EBxb2K37D0wrEmS-5RD&index=17
I found I could overcome my problem by changing the knexfile.js to something close to what is in the heroku documentation.
module.exports = {
development: {
client: 'sqlite3',
connection: {
filename: './data/lessons.db3',
},
useNullAsDefault: true,
pool: {
afterCreate: (conn, done) => {
conn.run('PRAGMA foreign_keys = ON', done);
},
},
},
production: {
client: 'pg',
connection: {
connectionString: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: false },
},
migrations: {
directory: __dirname + '/migrations',
},
seeds: {
directory: __dirname + '/seeds',
},
},
};
I managed to configure grunt to serve my application, but since it serves on localhost:9000, my api calls also go to port 9000 while my api is at port 3000, resulting in a 404 error.
After some research, I've decided I need to use grunt-connect-proxy to proxy my api calls to the right port. I've been beating my head against a wall going through every article, stack overflow question and the documentation, but I can't seem to get the configuration right. See my gruntfile below. Any help will have my undying gratitude.
// Invoke 'strict' JavaScript mode
'use strict';
module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2,
paths: ['public/styles/less']
},
files: {
"public/styles/css/main.css": "public/styles/less/main.less" // destination file and source file
}
}
},
watch: {
styles: {
files: ['public/styles/less/*.less'],
tasks: ['less'],
options: {
nospawn: true
}
}
},
connect: {
server: {
options: {
port: 8000,
base: 'public',
logger: 'dev',
hostname: 'localhost',
middleware: function (connect, options, defaultMiddleware) {
var proxy = require('grunt-connect-proxy/lib/utils').proxyRequest;
return [
// Include the proxy first
proxy
].concat(defaultMiddleware);
}
},
proxies: [
{
context: '/',
host: '127.0.0.1',
port: 3000,
https: false,
xforward: false,
headers: {
"x-custom-added-header": 'value'
},
hideHeaders: ['x-removed-header']
}
]
},
serve: {
options:{
port: 9000,
hostname: "127.0.0.1",
middleware: function(connect, options) {
return [
require('grunt-contrib-livereload/lib/utils').livereloadSnippet,
connect.static(options.base[0])
];
}
}
}
},
open: {
serve: {
path: 'http://localhost:<%= connect.serve.options.port%>/public'
}
},
regarde: {
serve: {
files:['public/index.html','public/script/*.js','public/script/**/*.js','public/styles/**/*.css','public/styles/less/*.less','public/views/*.html'],
tasks: ['livereload']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
//grunt.loadNpmTasks('grunt-contrib-clean');
//grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-connect-proxy');
grunt.registerTask('serve',['less','livereload-start','connect:serve','open:serve','regarde:serve']);
grunt.registerTask('server', function (target) {
grunt.task.run([
//'clean:server',
//'compass:server',
'configureProxies:server',
'connect:server',
'watch'
]);
});
};