Resetting json-server to the contents of db.json - json-server

NOTHING I do will get json-server to acknowledge changes to the db.json file. After reading https://github.com/typicode/json-server/issues/177. I have tried clearing the cache and closed all browser connections etc. (which is a pain enough in a workflow...) but still the data and schema persists in its last used state.
REST calls change the data, and the changes can be seen, that is working fine. But I need to change the schema...
How do I get json-server to restart using what is in the db.json file??

In case it helps anyone else. I started json-server from the wrong folder, so it created and loaded a default db.json. I did not catch the warning
Oops, db.json doesn't seem to exist
Creating db.json with some default data
on the very first startup. So I was altering the "wrong" file!!! Just a note in case anyone else gets caught out.

Steps:
Navigate to the path where json server is installed (json-server-master folder).
Rename the db.json as db.json_bkp
Restart the json server from command prompt
json-server --watch db.json
The db will be reset to the default values.

I've faced the similar issue.
Please check the db.json file that json-server is accessing and change it accordingly.
In my case, I was changing a different file than the correct one.
Please check for db.json file in the directory where you first installed/run the json-server. Change it according to your requirement.
Restart json-server so that changes will effect.

Go to the folder where your db.json file resides. then run the command json-server --watch db.json

I went through the same issue. I visited the the db directory (where the db.json file is situated).
Run json-server --watch db.json at the command prompt, while you are at the db directory.

Related

Changes Made In postgresql.conf File Are Not Being Reflected

I made some changes in postgresql.conf file like modifying search_path and changing port. But these changes were not being reflected. They were written in the file but were not being implemented. I used vim for editing the file.
I did those changes separately using terminal commands and they worked but can anyone tell me the reason why modifying postgres.conf was not working?
This happens sometimes because that changes was not stored/saved properly. So once you are done with the changes, save them and then run to make sure you are working on the correct file.
select name, context, setting, source, sourcefile from pg_settings where name in ('search_path', 'port');
Just don't forget to restart the server after changes in pg conf.
bin/pg_ctl -D {data-dir} restart

What causes error "Connection test failed: spawn npm; ENOENT" when creating new Strapi project with MongoDB?

I am trying to create a new Strapi app on Ubuntu 16.4 using MongoDB. After stepping through the tutorial, here: https://strapi.io/documentation/3.0.0-beta.x/guides/databases.html#mongodb-installation, I get the following error: Connection test failed: spawn npm; ENOENT
The error seems obvious, but I'm having issues getting to the cause of it. I've installed latest version of MongoDB and have ensured it is running using service mongod status. I can also connect directly using nc, like below.
$ nc -zvv localhost 27017
Connection to localhost 27017 port [tcp/*] succeeded!
Here is an image of the terminal output:
Any help troubleshooting this would be appreciated! Does Strapi perhaps log setup errors somewhere, or is there a way to get verbose logging? Is it possible the connection error would be logged by MongoDB somewhere?
I was able to find the answer. The problem was with using npx instead of Yarn. Strapi documentation states that either should work, however, it is clear from my experience that there is a bug when using npx.
I switched to Yarn and the process proceeded as expected without error. Steps were otherwise exactly the same.
Update: There is also a typo in Strapi documentation for yarn. They include the word "new" before the project name, which will create a project called new and ignore the project name.
Strapi docs (incorrect):
yarn create strapi-app new my-project
Correct usage, based on my experience:
yarn create strapi-app my-project
The ENOENT error is "an abbreviation of Error NO ENTry (or Error NO ENTity), and can actually be used for more than files/directories."
Why does ENOENT mean "No such file or directory"?
Everything I've read on this points toward issues with environment variables and the process.env.PATH.
"NOTE: This error is almost always caused because the command does not exist, because the working directory does not exist, or from a windows-only bug."
How do I debug "Error: spawn ENOENT" on node.js?
If you take the function that Jiaji Zhou provides in the link above and paste it into the top of your config/functions/bootstrap.js file (above module.exports), it might give you a better idea of where the error is occurring, specifically it should tell you the command it ran. Then run the command > which nameOfCommand to see what file path it returns.
"miss-installed programs are the most common cause for a not found command. Refer to each command documentation if needed and install it." - laconbass (from the same link, below Jiaji Zhou's answer)
This is how I interpret all of the above and form a solution. Put that function in bootstrap.js, then take the command returned from the function and run > which nameOfCommand. Then in bootstrap.js (you can comment out the function), put console.log(process.env.PATH) which will return a string of all the directories your current environment is checking for executables. If the path returned from your which command isn't in your process.env.PATH, you can move the command into a path, or try re-installing.

MongoDB data not stored in /data/db, although it is saving data... but where?

I'm completely new to MongoDB - I've installed all the programs and set it up so that I run mongod.exe and then mongo.exe. I created a new database called 'test' and inserted some data. However, I can't see any files being created in the /data/db directory. The data is definitely being stored somewhere, and when I closed down all the cmd boxes and started the processes again, the data I initially pushed onto the DB is still there.
I tried running the command 'db.adminCommand("getCmdLineOpts")' which apparently should show my DB Path, but it doesn't:
Can anyone offer some insight on this? Thanks :)
For using mongod.exe without parameters default is C:\data\db. Check start up parameters if you run server as service.
You can run this command to retrieve the dbpath if you in a Linux environment:
grep dbpath /etc/mongod.conf
db.adminCommand("getCmdLineOpts") is not running the db path as it was not specified a a command line parameter when the mongod process was started. It seems the db path is configured in the mongod.conf configuration file and the above command should return it.

FISH error upon startup to access a file that does exist

On an Ubuntu 14.04, I have started to receive the following warning (or error) each time I start a new session in terminal :
Unable to make or open a FIFO for universal variables with path '/run/user/0/fishd.12c79b706e7a.notifier': Permission denied
When I try to look into this file, the file does not exist at all.
I had a similar problem setting my terminal to fish in IntelliJ IDEA on Manjaro.
Every time I opened up the terminal, it kept printing the following error message;
Unable to open universal variable file '/opt/intellij-idea-ultimate-edition/plugins/terminal/fish/fish_variables': Permission denied
The solution I used, while not ideal did stop the error message - it's trying to write to a root controlled location from user land. from the terminal type the following command:
chown -R USER:USER /opt/intellij-idea-ultimate-edition/plugins/terminal/fish
This is fish issue #2222.
The problem seems to be that you get the wrong value for $XDG_RUNTIME_DIR. In that issue the reporter said su -l caused it, which, unlike what the documentation said, did not clear $XDG_RUNTIME_DIR or set it again to the wrong value.
I get a much more benign issue on fish 2.2.0 (and current git):
fish: No TTY for interactive shell (tcgetpgrp failed)
setpgid: Inappropriate ioctl for device
which seems not to break anything, so I can only recommend upgrading.

Not able to start Sphinx Search- error 1067

I am trying to install the Sphinx Search Server. I followed the steps given here http://itsonrail.wordpress.com/2010/05/23/installing-sphinx-on%C2%A0windows/
I added C:\Sphinx\bin to environment path and Sphinx Search is listed in the Services panel. When I try to start it, this error occurs:
Windows could not start SphinxSearch service on local computer
Error: 1067 The process terminated unexpectedly.
Please help me solving this problem. Thanks in advance.
I trid this http://sphinxsearch.com/forum/view.html?id=2684 but it didn't help.
I had the same error in my Windows 7 x64. The step below helped to solve my problem:
Create folders data and log in C:\Sphinx.
Then try to start sphinx with cmd:
C:\sphinx\bin>searchd
I have faced the same problem and eventually moved the sphnix.conf to C:\Sphinx\bin\sphnix.conf from root and the services starts. Please try this. (Please make sure there are data\, log\ directories in the root with write permission)
It is looking like your configuration is not setup properly. Have you tried to run search daemon from sphinx directory path via command prompt?
C:\sphinx\bin> searchd
C:\sphinx\bin>indexer --rotate –all
Also please ensure the log via search.log or windows event log.
If it is not running after this than try to reinstall it again
I hope it will work for you
Error 1067 doesn't say much about the problem, except that the process terminated unexpectedly. Try looking some more informations in searchd.log.
I've got same error code when I tried to update Sphinx with newer version.
In the log file, I've found
FATAL: no valid indexes to serve
My problem was that I tried running new version of Sphinx using index files created with an older version. It was solved by deleting all old index files and creating new indexes.
==>> close your cmd window and restart the sphinxsearch service...
I got this error suddenly, when Shpinx was working fine yesterday. Turns out the query log file was hitting 4Gb in size. I deleted it, and service started with no problems.
Make sure all the folders defined in the conf file actually exist. I was missing the LOG folder and that's why I was getting the error. Once I added the folder, the problem was solved.