Centrifuge not using MongoDB? - mongodb

I just installed centrifuge (https://centrifuge.readthedocs.org/en/latest/) and created a configuration.json file and placed it in /var/www/ folder.
When I try to run centrifuge centrifuge config = /var/www/configuration.json, the server starts. However when I go to the default path http://localhost:8000 in the admin panel it keeps saying DataStructure used as SQLite.
Here's my configuration.json file
{
"password": "admin",
"cookie_secret": "secret",
"api_secret": "secret",
"structure": {
"storage": "centrifuge.structure.mongodb",
"settings": {
"host": "localhost",
"port": 27017,
"name": "centrifuge",
"pool_size": 10
}
},
state: null
}
I checked and the MongoDB server is running on port 27017.

It seems you are starting Centrifuge using incorrect command line arguments. Try copy and paste into your terminal:
centrifuge --config=/var/www/configuration.json

Related

How can I start nest app with Postgress DB on Win 10?

I'm front dev and I need to test locally my front app with backend (nest js) and postgresql DB. Who can write me the right way How to run and connect to DB ? I get some errors on app start. I work on win 10 and there is my steps for start this app.
install postgresql
npm install for my nest js app
run pgAdmin4 and create DB for my app
npm start
There is my ormconfig
module.exports = {
"type": "postgres",
"host": process.env.POSTGRES_HOST || "localhost",
"port": process.env.POSTGRES_PORT || 5432,
"username": process.env.POSTGRES_USER || "", //<- Here I try to set all possible username
"password": process.env.POSTGRES_PASSWORD || "", //<- Here I try to set all possible password
"database": process.env.POSTGRES_DB || "my_database",
"entities": ["dist/**/*.entity{.ts,.js}"],
"synchronize": true,
"logging": true
}
There is error that I encountered
error
Also on other computer I try to do this and I get error like
[Nest] ERROR [TypeOrmModule] Unable to connect to the database.
FATAL: password authentication failed for user "postgres" (postgresql 14 with pgAdmin 4)
In your typeormconfig.ts , you should write this:
export class PostgresTypeormConfiguration implements TypeOrmOptionsFactory
{
createTypeOrmOptions(connectionName?: string): TypeOrmModuleOptions | Promise<TypeOrmModuleOptions> {
const TypeOrmOptions:TypeOrmModuleOptions=
{
type: "postgres",
host: process.env.POSTGRES_HOST ,
port: process.env.POSTGRES_PORT ,
username: process.env.POSTGRES_USER ,
password: process.env.POSTGRES_PASSWORD ,
database: process.env.POSTGRES_DB,
entities: ["dist/**/*.entity{.ts,.js}"],
synchronize: true,
logging: true
}
return TypeOrmOptions
}
}
and you should define this in your module like this:
#Module({
imports:[TypeOrmModule.forRootAsync({useClass:PostgresTypeormConfiguration})]
})
note: if you still got an error , you wrote one of the config option wrong in your .env file or you did not define .env file in your configModule

Loopback 4 test configurations are not picked up

I followed Loopback4 datasources documentation and placed sample.datasource.json and sample.test.datasource.json files under src/datasources. Whenever I run npm run test my repository is injected with original datasource but not the test datasource.
My datasource configuration file sample.datasource.json is
{
"name": "sample",
"connector": "postgresql",
"url": "postgres://postgres:user#localhost:5432/somedb",
"host": "localhost",
"port": 5432,
"user": "postgres",
"password": "****",
"database": "somedb"
}
and my test configuration file sample.test.datasource.json is
{
"name": "sample",
"connector": "memory",
"localStorage": "sample-test",
"debug": true
}
Here is my repository file sample.repository.ts placed under src/repositories.
export class SampleRepository extends DefaultCrudRepository<SomeModel,string> {
constructor(
#inject('datasources.sample') dataSource: SomeDataSource,
) {
super(SomeModel, dataSource);
}
}
I exported NODE_ENV to "test" and tried to run npm run test.
Hello from the LoopBack team :)
LoopBack 4 does not support environment specific configuration yet. We are discussing this feature in the GitHub issue #1464, there is also a discussion about modifying datasource configuration specifically for tests - see issue #1396.
There are workaround possible, see the following resources for inspiration:
https://loopback.io/doc/en/lb4/Deploying-to-IBM-Cloud.html#updating-application
https://itnext.io/loopback-4-database-configuration-8f085399268

Vapor MongoDB Provider Error

I am trying to run a Vapor app on my local machine and have MongoDb installed and running.
I have this as my mongo.json: {
"user": "test",
"password": "password",
"database": "reading_journal",
"host": "127.0.0.1",
"port": 2701
}
which is correct in terms of the info for the local DB.
My main.swift:
import Vapor
import FluentMongo
import VaporMongo
let drop = Droplet(providers: [VaporMongo.Provider.self])
drop.get { req in
let lang = req.headers["Accept-Language"]?.string ?? "en"
return try drop.view.make("welcome", [
"message": Node.string(drop.localization[lang, "welcome", "title"])
])
}
drop.resource("users", UserController())
drop.resource("posts", PostController())
drop.run()
Yet in the log I get: "Could not initialize provider Provider: Socket failed with code 61 ("No data available") [connectFailed] "Unknown error"
Is there some other initialization that needs to be done? This is a brand new MongoDB DB.
Any help would be greatly appreciated!
In my case, I had to add "host": "0.0.0.0" in the mongo.json
That error usually happens if MongoDB is not running on the correct port. Make sure whatever you have in your mongo.json file matches what port MongoDB is running on.

Can i use replica set name to connect via mongo-connector

I would like to know, is there a way we can replicate from one mongo replica set to another via mongo-connector? As per mongo documentation we can connect two mongo instances via mongo-connector by using a command as in the example below, but I would like to pass replica set name or use a configuration file instead of passing server:port name in command line.
Mongo Connector can replicate from one MongoDB replica set or sharded cluster to another using the Mongo DocManager. The most basic usage is like the following:
mongo-connector -m localhost:27017 -t localhost:37017 -d mongo_doc_manager
I also tried config.json option by creating below config.json file but it has failed.
{
"__comment__": "Configuration options starting with '__' are disabled",
"__comment__": "To enable them, remove the preceding '__'",
"mainAddress": "localhost:27017",
"oplogFile": "C:\Dev\mongodb\mongo-connector\oplog.timestamp",
"verbosity": 2,
"continueOnError": false,
"logging": {
"type": "file",
"filename": "C:\Dev\mongodb\mongo-connector\mongo-connector.log",
"__rotationWhen": "D",
"__rotationInterval": 1,
"__rotationBackups": 10,
"__type": "syslog"
},
"docManagers": [
{
"docManager": "mongo_doc_manager",
"targetURL": "localhost:37010",
"__autoCommitInterval": null
}
]
}
yes its possible to connect to a replica set or a shard server using mongo connector.
{
mongo-connector -m <mongodb server hostname>:<replica set port> \
-t <replication endpoint URL, e.g. http://localhost:8983/solr> \
-d <name of doc manager, e.g., solr_doc_manager>
}
you can also also pass a connection string to the mongo-connector such as
{
mongo connector -m mongodb://db1.example.net,db2.example.net:2500/?replicaSet=test&connectTimeoutMS=300000
}
to specify specifc config files you can use
{ mongo-connector -c config.json }
where config.json is your config file.
I'm able to resolve my issue by entering backslash '\' for my windows directory path.Here is my updated config file for reference. Thanks to ShaneHarveyNot able to use Configuration file for connecting to mongo-connector
{
"__comment__": "Configuration options starting with '__' are disabled",
"__comment__": "To enable them, remove the preceding '__'",
"mainAddress": "localhost:27017",
"oplogFile": "C:\\Dev\\mongodb\\mongo-connector\\oplog.timestamp",
"noDump": false,
"batchSize": -1,
"verbosity": 2,
"continueOnError": false,
"logging": {
"type": "file",
"filename": "C:\\Dev\\mongodb\\mongo-connector\\mongo-connector.log",
"__format": "%(asctime)s [%(levelname)s] %(name)s:%(lineno)d - %(message)s",
"__rotationWhen": "D",
"__rotationInterval": 1,
"__rotationBackups": 10,
"__type": "syslog",
"__host": "localhost:27017"
},
"docManagers": [
{
"docManager": "mongo_doc_manager",
"targetURL": "localhost:37017",
"__autoCommitInterval": null
}
]
}

Access Parse Dashboard without SSL

I recently created Parse Dashboard on my server.My server does't have SSL
,how can i connect without ssl
How to solve Parse Dashboard can only be remotely accessed via HTTPS using a Configuration file
First create a parse-dashboard-config.json and file should contain the following code
{
"apps": [
{
"serverURL": "http://example.com:1337/parse",
"appId": "yourappid",
"masterKey": "yourmasterkey",
"appName": "appname"
}
],
"users": [
{
"user":"user",
"pass":"pass"
}
]
}
On terminal
parse-dashboard --config parse-dashboard-config.json --allowInsecureHTTP