lmenezes / cerebro

MIT License
5.51k stars 714 forks source link

db - Connection is not available #391

Open Theoooooo opened 5 years ago

Theoooooo commented 5 years ago

Hello, As i found while doing some researchs, there is still permission or ressource issue when you install a package already (or not) build from this project. I install the lastest version of cerebro for CentOS7 with the latest .rpm available.

After the installation i pimped out the configuration file and modify the .service file to change the IP and the PORT on which the service will be listening. But after that the service can't create the .db file.

The workaround i found in the 0.8.3 version was to mouve out the temporary files created by cerebro with add this line in the .service file :

ExecStart=/home/user/cerebro-0.8.3/bin/cerebro \
                                          -Djava.io.tmpdir=/home/user/cerebro-0.8.3 \
                                          -Dhttp.port=${PORT} \
                                          -Dhttp.address=${HOST}

In this version, the configuration file for the service are installed to /usr/share/cerebro/conf with a symbolic link to /etc/cerebro. Even if there is full permission on the /etc/cerebro directory, java can't still create the database.

It would be great if in the future, the installation take care about this issue that is mostly annoying when you are installed the service every 3 or 4 weeks. I always forget what are the steps to follow and pass around this issue.

Maybe that's not a permission problem or something like that, let's investigate

sznicolas commented 4 years ago

Hello,

Almost the same problem here ; on Debian 9.11. I installed the package downloaded here and openjdk, then systemclt start cerebro Logs :

java.sql.SQLTransientConnectionException: db - Connection is not available, request timed out after 30001ms.
[...]
Caused by: java.sql.SQLException: opening db: './cerebro.db': Permission denied

Found in /lib/systemd/system/cerebro.service:

WorkingDirectory=/usr/share/cerebro
User=cerebro

But this dir is only writable by root.

Workaround: Just open /etc/cerebro/application.conf , comment out line 18 and uncomment line 17 :

17 data.path: "/var/lib/cerebro/cerebro.db" 18 #data.path = "./cerebro.db"

Then systemctl start cerebro

moliware commented 4 years ago

So, far the only solution is exactly what @sznicolas said. I guess the .deb should have the data.path property configured in a different way to avoid manual intervention.

thorian93 commented 4 years ago

One comment: I found that setting the data.path: in /etc/cerebro/application.conf does the charme for me. I even used the suggested but commented path /var/lib/cerebro/cerebro.db. So in my opinion it should suffice to set this value by default.

rful011 commented 8 months ago

you don't need to change the systemd service file to deal with the db write access. You can tweak /etc/default/cerebro.

I created two subdirs in /usr/share/cerebro (db and tmp) both owned by cerebro. Then tweaked the application.conf: data.path: "/usr/share/cerebro/db/cerebro.db" and added JAVA_OPTS="-Djava.io.tmpdir=/usr/share/cerebro/tmp" to /etc/default/cerebro