PM2 Refuses to ask for SSH key password no matter what? - pm2

Config;
module.exports = {
apps: [
{
name: 'My App',
script: './dist/app.js',
// Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development',
},
env_production: {
NODE_ENV: 'production',
},
},
],
deploy: {
production: {
key: '~/.ssh/id_rsa',
user: '....',
host: 'xx.xxx.xxx.xx',
ref: 'origin/master',
repo: 'git#bitbucket.org:..../....',
path: '/srv/my-app',
ssh_options: ['StrictHostKeyChecking=no', 'PasswordAuthentication=yes'],
'post-deploy':
'yarn && yarn build && pm2 startOrRestart ecosystem.config.js --env production --update-env',
},
},
};
Currently 'PasswordAuthentication=yes' will return git#bitbucket.org: Permission denied (publickey).
If I set it to no, it will return Permission denied (publickey,password).
At no point does it ever prompt me for the SSH key password, it just straight up denies it. It only ever asks for the system password.
How can I solve this since their documentation is pretty garbage and the only thing they suggest on there is making an SSH config which I have done and still doesn't work.

Related

truffle doesnt migrate to new chain

I was following some tutorial and everything worked fine. I decided to make a new project to test myself out. After writing the contracts and making a new ganache workspace, when I run truffle migrate, it just says:
Compiled successfully using:
- solc: 0.8.7+commit.e28d00a7.Emscripten.clang
It doesnt say anything regarding the migrations.
When I run truffle networks, it says: Contracts have not been deployed to any network.
Also, when I run truffle develop, when it lists down the accounts, its showing the old accounts from my older ganache workspace.
truffle-config.js:
module.exports = {
networks: {
ganache: {
host: "127.0.0.1",
port: 7545,
network_id: "*"
},
},
compilers: {
solc: {
version: "^0.8",
optimizer: {
enabled: true,
runs: 200
},
},
},
contracts_directory: './src/contracts/',
contracts_build_directory: './src/abis/',
mocha: {
useColors: true,
},
};

How to fix "Unknown network "ganache". See your Truffle configuration file for available networks."

I'm trying to deploy a contract to rinkeby. I'm using the following command:
$ truffle migrate --networks rinkeby
Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Voting.sol
> Artifacts written to ./public/contracts/build/
> Compiled successfully using:
- solc: 0.5.8+commit.23d335f2.Emscripten.clang
Unknown network "ganache". See your Truffle configuration file for available networks.
Truffle v5.0.22 (core: 5.0.22)
Node v11.6.0
It works witch ganache-cli but it doesn't work with rinkeby, because its giving me the error of Unknown network "ganache". See your Truffle configuration file for available networks as showed in the result above.
This is my truffle-config.js:
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "./public/contracts/build/"),
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: 1000,
gas: 4612388,
gasPrice: 25000000000,
total_accounts: 20,
mnemonic
},
rinkeby: {
provider: () => new HDWalletProvider(mnemonic, infuraURL),
network_id: 4,
gas: 4612388,
gasPrice: 25000000000,
},
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
}
};
For anyone having this error, my problem was that I was writting wrong the command. The correct form should be:
truffle migrate --network rinkeby # Network is without the 's'

NestJs TypeORM unable to connect to mysql

I am trying to connect to MySQL. I have defined the db connection vars in a .env file in my root dir, and I am initializing the connection in the app.module.ts file.
the only issue I am facing now is when creating or running migrations using the CLI,
I followed the typeorm docs here to configure the connection, however when I run typeorm migrate:create -n myNewTable, it should create the migration file in the specified directory, what it does instead is it creates it in the app root directory,
similarily, I solved the issue by using the -d flag after the typeorm migrate:create to specify the directory, however when I try running my migration files, I get this
No connection options were found in any of configurations file.
here is my app.module.ts file.
TypeOrmModule.forRoot({
type: 'mysql',
host: process.env.TYPEORM_HOST,
port: parseInt(process.env.TYPEORM_PORT, 10),
username: process.env.TYPEORM_USERNAME,
password: process.env.TYPEORM_PASSWORD,
database: process.env.TYPEORM_DATABASE,
synchronize: false,
migrations: [process.env.TYPEORM_MIGRATIONS],
cli: {
migrationsDir: process.env.TYPEORM_MIGRATIONS_DIR,
},
logging: (process.env.TYPEORM_LOGGING === 'true') ? true : false,
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
}),
and here is my .env file
# use .ts for development, .js for production
TYPEORM_CONNECTION = mysql
TYPEORM_HOST = 127.0.0.1
TYPEORM_PORT = 3306
TYPEORM_USERNAME = <username>
TYPEORM_PASSWORD = <password>
TYPEORM_DATABASE = <dbname>
TYPEORM_SYNCHRONIZE = true
TYPEORM_MIGRATIONSRUN = true
TYPEORM_LOGGING = true
TYPEORM_ENTITIES = src/**/**.entity.ts
#TYPEORM_ENTITIES = src/**/**.entity.js
TYPEORM_SUBSCRIBERS = src/subscriber/*.ts
#TYPEORM_SUBSCRIBERS = src/subscriber/*.js
TYPEORM_MIGRATIONS = src/database/migration/*.ts
TYPEORM_MIGRATIONS_DIR = src/database/migration
TYPEORM_SUBSCRIBERS_DIR = src/subscriber
any help/hint is highly appreciated, thanks in advance.
Try to change your entities dir in ormconfig.json or .env, it worked for me as:
"entities": ["dist/**/**.entity{.ts,.js}"]
There is an issue, how you are loading the **TypeOrmModule**. The way, you had loaded, it is synchronous so it simply means custom env will not be available instantly on application boot.
So what you can do, is to load TypeOrmModule` asynchronusly like below -
ConfigModule.forRoot({
isGlobal: true, // [REQUIRED if want to use env gloablly among all modules]
}),
TypeOrmModule.forRootAsync({
useFactory: () => ({
type: 'mysql',
host: process.env.TYPEORM_HOST,
port: parseInt(process.env.TYPEORM_PORT, 10),
username: process.env.TYPEORM_USERNAME,
password: process.env.TYPEORM_PASSWORD,
database: process.env.TYPEORM_DATABASE,
synchronize: false,
migrations: [process.env.TYPEORM_MIGRATIONS],
cli: {
migrationsDir: process.env.TYPEORM_MIGRATIONS_DIR,
},
logging: process.env.TYPEORM_LOGGING === 'true' ? true : false,
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
}),
}),
You should specify the connection in ormconfig.json in the project root folder.
looking something like this
{
"type": "postgres",
"host": "localhost",
"port": <port>,
"username": "",
"password": "",
"database": "",
"entities": ["dist/**/*.entity{.ts,.js}"],
"synchronize": true,
"logging": "all",
"migrations": [
"migrations/**/*.js"
],
"subscribers": [
"subscriber/**/*.js"
],
"cli": {
"migrationsDir": "<migrations directory>",
"subscribersDir": "<subscriber directory>"
}
}
Read more in the documentation chapter
On a side note, you might have to remove your dist/ folder for changes to get through.

#nuxtjs/pwa does not generate sw.js with local system hosts information

I would like to apply PWA in nuxt(#2.3.4) web application.
The operating system is OSX latest.
So I have installed #nuxtjs/pwa and add some config to nuxt.config.js.
These are what I have added
module.exports = {
...
modules: [
['#nuxtjs/pwa', {icon : false}]
],
workbox : {
dev: true,
debug: true
},
manifest : {
viewport: 'width=device-width, initial-scale=1',
theme_color: '#3B8070'
},
...
}
And build with NODE_ENV=production and start.
I am able to find sw.js in localhost:9000, but it is not available with
local.jy.net:9000.
I was expecting the same result since I register that hostname on my hosts file.
Here is what I have in /private/etc/hosts.
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 Juneui-MacBook-Pro.local
127.0.0.1 local.jy.net aad901eb546340cc9a69b0b030b124fc.jy.net
How could I make #nuxtjs/pwa refers system hosts variables?
If you need more information, add reply then I will provide as possible as I can. Thanks.
The #nuxtjs/pwa package is looking for the build.publicPath option: https://github.com/nuxt-community/pwa-module/blob/9f27d5cdae0e0341d6d4b4f6814f91db6eab1432/packages/manifest/index.js#L24
Adding this option to your nuxt.config.js should do the trick:
module.exports = {
...
modules: [
['#nuxtjs/pwa', {icon : false}]
],
workbox : {
dev: true,
debug: true
},
manifest : {
viewport: 'width=device-width, initial-scale=1',
theme_color: '#3B8070'
},
build: {
publicPath: '//local.jy.net:9000/pwa/',
}
...
}
You can find more information about the publicPath property here: https://nuxtjs.org/api/configuration-build#publicpath

Deprecated: `config.adapters.default` Sails.js

When I lift my sails project I get these warnings on terminal
debug: Deprecated: config.adapters.default debug: (see
http://links.sailsjs.org/docs/config/connections) debug: For now, I'll
pretend you set config.models.connection.
debug: Deprecated: config.adapters debug: (see
http://links.sailsjs.org/docs/config/connections) debug: For now, I'll
pretend you set config.connections.
debug: Deprecated: config.adapters.*.module debug: (see
http://links.sailsjs.org/docs/config/connections) debug: For now, I'll
pretend you set config.connections["disk"].adapter.
And my data is not stored in mysql DB.
This is my api model code
module.exports = {
schema:true,
tableName: 'BusStop',
adapters: 'mysql-adapter',
migrate: 'safe',
attributes: {
stopID:{
type: 'int'
},
stopName:{
type: 'string'
},
latitude:{
type: 'float'
},
longitude:{
type: 'float'
}
}
};
This is my local.js code
module.exports = {
port: process.env.PORT || 1337,
environment: process.env.NODE_ENV || 'development',
adapters:{
'default': 'disk',
disk:{
module:'sails-disk'
},
'mysql-adapter': {
module : 'mysql-sails',
host : '127.0.0.1',
user : 'root',
password : '',
database : 'PublicTransport',
schema : true
}
}
};
And this is my connections.js code
module.exports.connections = {
localDiskDb: {
adapter: 'sails-disk'
},
'mysql-adapter': {
module : 'sials-mysql',
host : '127.0.0.1',
port : 3306,
user : 'root',
password : '',
database : 'PublicTransport'
},
someMongodbServer: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017,
},
somePostgresqlServer: {
adapter: 'sails-postgresql',
host: 'YOUR_POSTGRES_SERVER_HOSTNAME_OR_IP_ADDRESS',
user: 'YOUR_POSTGRES_USER',
password: 'YOUR_POSTGRES_PASSWORD',
database: 'YOUR_POSTGRES_DB'
}
};
I want to know how can I remove these Deprecated warnings and why my data is not being stored in the Database.
Looks like the links in those deprecation warnings are incorrect. For information on how to configure Sails connections, see http://sailsjs.org/#/documentation/reference/sails.config/sails.config.connections.html.
You should be able to make those messages go away by following their instructions regarding what config keys to set.
In order to set a connection for a specific model, you now set the connection property:
module.exports = {
schema:true,
tableName: 'BusStop',
connection: 'mysql-adapter', // "adapter" is now "connection
migrate: 'safe',
attributes: {...}
}
In order to specify the adapter to use for a connection, use the adapter key, not module; you're already doing this in most of your connections, you just need to update mysql-adapter.
In your config/local.js you're using the deprecated adapters key to set up connections; use connections instead.
Lastly, in order to set a default connection for all of your models, you do as the deprecation message says and set sails.config.models.connection rather than sails.config.adapters.default; you can do so easily in the config/models.js file, or in your config/local.js like so:
module.exports = {
models: {
connection: 'mysql-adapter'
},
...more config...
}
This warning can also be generated if your project has an config/adapters.js file. If the file is empty it can be deleted and Zap the warning is gone.If it contains code then you will need to migrate it to the correct path config/models.js and config/connections.js