Odoo app list in docker is not updated via odoo.conf file or when exec into the container - postgresql

I have a docker-compose file with two services: odoo:latest and postgres:13.
I try to update app list in debug mode http://localhost:8070/web?debug=1
but nothing happens.
odoo service has volumes section:
`volumes:
- ./extra-addons:/mnt/extra-addons
- data:/var/lib/odoo
- ./config:/etc/odoo`
that corresponds to a this directory:
.
├── config
│ └── odoo.conf
├── docker-compose.yml
└── extra-addons
├── __init__.py
└── __manifest__.py
Content of of oodo.conf file:
[options]
addons_path = /mnt/extra-addons
data_dir = /var/lib/odoo
Content of manifest.py
{
'name': 'estate',
'depends': [
'base_setup',
],
"installable": True,
"application": True,
"auto_install": False,
}
I also tried to update app list in the terminal.
When I exec in odoo service and issue this command:
/usr/bin/odoo -p 8071 --db_host=172.17.0.2 --db_user=odoo --db_password=odoo -d odoo -u estate
I get:
odoo: Odoo version 16.0-20221025
odoo: Using configuration file at /etc/odoo/odoo.conf
odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/var/lib/odoo/addons/16.0', '/mnt/extra-addons']
odoo: database: odoo#172.17.0.2:default
odoo.sql_db: Connection to the database failed
Traceback (most recent call last):
File "/usr/bin/odoo", line 8, in
odoo.cli.main()
...
File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 638, in borrow
result = psycopg2.connect(
File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "172.17.0.2", port 5432 failed: Connection timed out
Is the server running on that host and accepting TCP/IP connections?
THANK YOU!

Every module needs it's own directory.
As i see, you've put __init__.py and __manifest__.py inside extra_addons folder.
extra_addons should contain module folders, so correct structure should be:
.
├── config
│ └── odoo.conf
├── docker-compose.yml
└── extra-addons
└── estate
├── __init__.py
└── __manifest__.py
where estate is your module code (which for best practice should be the same as "name" key in manifest dictionary)
Furthermore, if you added ./extra-addons:/mnt/extra-addons volume after you ran your docker-compose, you should run it again.
This will only re-create your odoo container since postgres container has not changed, meaning you won't lose any data.

Related

Micronaut not connecting to db in yml

I have created a new environment for my application and called it docker. I'm trying stuff out so I set it like this:
application-docker.yml
micronaut:
application:
name: time
server:
netty:
access-logger:
enabled: true
logger-name: access-logger
datasources:
default:
url: jdbc:postgresql://db:5432/postgres
driverClassName: org.postgresql.Driver
username: postgres
password: postgres
schema-generate: CREATE_DROP
dialect: POSTGRES
schema: time
jpa.default.properties.hibernate.hbm2ddl.auto: update
flyway:
datasources:
default:
enabled: true
schemas: time
...
However when I try to run my app like this:
java -jar target/timeshare-0.1.jar -Dmicronaut.environments=docker -Dcom.sun.management.jmxremote -Xmx128m
If fails... because it can't connect to localhost!
08:11:00.949 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
08:11:02.013 [main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:285)
Why is it trying to connect to localhost? What am i missing?
It seems that Micronaut is not able to locate application-docker.yml file and then it is using the default one.
Because you can use for example -Dmicronaut.environments=not-existing-profile and even if it does not exist, it does not show any error.
So, make sure you have application-docker.yml file in the src/main/resources directory and also that the file is really exported into the result jar during build and is located in the root of the jar archive:
target/timeshare-0.1-all.jar
├── com
├── META-INF
├── org
├── application-docker.yml
├── application.yml
├── logback.xml
...
How are you building the result jar? When you use the shadowJar task then it must contain everything.
Another option is to use MICRONAUT_ENVIRONMENTS system variable:
export MICRONAUT_ENVIRONMENTS=docker
But this behaves the same way as -Dmicronaut.environments=docker startup option.
Another option is to specify exact path to the application-docker.yml configuration file by the micronaut.config.files startup option:
java -jar target/timeshare-0.1-all.jar -Dmicronaut.config.files=/some/external/location/application-docker.yml

How can I mount an absolute host path as a named volume in docker-compose?

I've already tried the solution in this stackoverflow thread. It did not work for me, as shown below.
Here's my docker-compose.yml file:
version: "3.7"
services:
db:
image: mysql
volumes:
- data:/var/lib/mysql
volumes:
data:
driver_opts:
type: none
device: /usr/local/opt/mysql/mywebsite.com
o: bind
Here's the result of docker-compose up:
$ docker-compose up
Creating volume "mycontainer_data" with default driver
Recreating 45bc03b2c674_mycontainer_db_1 ... error
ERROR: for 45bc03b2c674_mycontainer_db_1 Cannot create container for service db: error while mounting volume with options: type='none' device='/usr/local/opt/mysql/mywebsite.com' o='bind': no such file or directory
ERROR: for db Cannot create container for service db: error while mounting volume with options: type='none' device='/usr/local/opt/mysql/mywebsite.com' o='bind': no such file or directory
ERROR: Encountered errors while bringing up the project.
Instead of type: none, I have also tried type: volume and type: bind, but I got the same error.
The directory clearly exists:
$ ls -al /usr/local/opt/mysql/
...
drwxr-xr-x 2 cameronhudson staff 64 Jun 10 10:32 mywebsite.com
...
There were 2 reasons why my configuration wasn't working.
First, Docker does not follow symlinks, and the mysql directory is a symlink:
$ ls -al /usr/local/opt | grep mysql
lrwxr-xr-x 1 cameronhudson admin 22 Jan 23 17:42 mysql -> ../Cellar/mysql/8.0.13
However, even after using a path without any symlinks, /databases/mywebsite.com, I continued the experience the same no such file or directory error.
I found that if I changed my docker-compose.yml file to mount this directory as a nameless volume, I got a different, more reasonable error:
version: "3.7"
services:
db:
image: mysql
volumes:
- /databases/mywebsite.com:/var/lib/mysql
The new error:
ERROR: for mycontainer_db_1 Cannot start service db: b'Mounts denied: \r\nThe path /databases/mywebsite.com\r\nis not shared from OS X and is not known to Docker.\r\nYou can configure shared paths from Docker -> Preferences... -> File Sharing.\r\nSee https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.\r\n.'
After I added this path in Docker Desktop, I was able to up the services using my original configuration. It also worked with type: none, type: volume, type: bind, or leaving type out altogether.

Setting up Vapor and MongoKitten

After successfully deploying on localhost (0.0.0.0:8080)
While I pushed the code to git for heroku,
I am getting error on heroku.
Cannot connect to MongoDB
Process exited with status 0
Inside package file I added
dependencies: [
.Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 1),
.Package(url: "https://github.com/OpenKitten/MongoKitten.git", majorVersion: 3)
],
Inside main.swift the program exists on this line
let mongoDatabase = try Database(mongoURL: "mongodb://localhost/mydatabase")
Additional info: I believe that on commit there is something which is left out by the SourceTree.
As the same code is also not working after checkout on a different machine. And the code is compiling perfect.
here is an info how to get the DATABASE_URL for postgres but it shold be the same for mongo DB:
heroku addons:create heroku-postgresql:hobby-dev
after some minits preparation:
heroku config
there shold be the url
in your Procfile (you created with vapor init) you can add the db url:
our text editor and update it so that looks like the below.
web: App --env=production --workdir="./"
web: App --env=production --workdir=./ --config:servers.default.port=$PORT --config:postgresql.url=$DATABASE_URL
this is the db url we add --config:postgresql.url=$DATABASE_URL
Save Procfile and type git push heroku master
after some time it should working.
you should change the name postgresql.url to your mongo db confog name (depending which mongo addon you use)

Chef server 12 reconfiguration is not working on Ubuntu 14.04

I'm trying to install a Chef server on an Ubuntu 14.04 box. I've downloaded the .deb file from the site and installed with sudo dpkg -i chef-server-core_12.0.8-1_amd64.deb but when I do sudo chef-server-ctl reconfigure all goes well until it reaches the postgresql part:
Running handlers:
[2015-05-03T23:16:07-04:00] ERROR: Running exception handlers
Running handlers complete
[2015-05-03T23:16:07-04:00] ERROR: Exception handlers complete
[2015-05-03T23:16:07-04:00] FATAL: Stacktrace dumped to /opt/opscode/embedded/cookbooks/cache/chef-stacktrace.out
Chef Client failed. 44 resources updated in 198.107797872 seconds
[2015-05-03T23:16:08-04:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: private-chef_pg_database[opscode-pgsql] (private-chef::postgresql line 127) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[create_database_opscode-pgsql] (/opt/opscode/embedded/cookbooks/cache/cookbooks/private-chef/providers/pg_database.rb line 13) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of createdb --template template0 --encoding UTF-8 opscode-pgsql ----
STDOUT:
STDERR: createdb: could not connect to database template1: FATAL: role "opscode-pgsql" does not exist
---- End output of createdb --template template0 --encoding UTF-8 opscode-pgsql ----
Ran createdb --template template0 --encoding UTF-8 opscode-pgsql returned 1
Am I missing any step? The installation instruction does not say anything about any other middle task to perform.
Thank you very much for any help you can give me.
Saw exact same error installing chef-server-core-12.0.8-1.el6.x86_64.rpm on RHEL6.6. Had gone through every pre-req step listed at https://docs.chef.io/install_server_pre.html ... finally chalked it up to having multiple versions of Postgres on the system.
Attempted the same install and reconfigure command (chef-server-ctl reconfigure) on a system without Postgres installed and had success.
HTH.
Cannot reproduce your problem. The installation of chef server 12.0.8-1 worked fine on my kitchen/vagrant setup
Example
├── Berksfile
├── .kitchen.yml
├── roles
   └── chef-server.json
Berksfile
source "https://supermarket.chef.io"
cookbook "chef-server"
kitchen.yml
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: ubuntu-14.04
driver:
network:
- ["private_network", {ip: "192.168.38.34"}]
customize:
memory: 4096
suites:
- name: default
run_list:
- role[chef-server]
attributes:
roles/chef-server.json
{
"name": "chef-server",
"description": "Chef server",
"run_list": [
"recipe[chef-server]"
]
}

Heroku postgres connection: "Is the server running locally and accepting connections on Unix domain socket"

I am setting up a new dev environment, followed the django setup tutorial and am having issues. Here is what I get when I try to run syncdb
Running `python doccal/manage.py syncdb` attached to terminal... up, run.1
Traceback (most recent call last):
File "doccal/manage.py", line 14, in <module>
execute_manager(settings)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.py", line 459, in execute_manager
utility.execute()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 371, in handle
return self.handle_noargs(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/com
mands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/__init_
_.py", line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgre
sql_psycopg2/base.py", line 177, in _cursor
self.connection = Database.connect(**conn_params)
File "/app/.heroku/venv/lib/python2.7/site-packages/psycopg2/__init__.py", lin
e 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: could not connect to server: No such file or director
y
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I have setup this same project before using the same steps and have never had a problem. I did, a few weeks ago, get an email that Heroku was migrating away from shared databases and assume this is somehow involved.
Also, I did notice two NEW steps in the tutorial, namely, installing dj-database-url and adding these lines to settings.py
import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
I have tried to run this both with and without these lines and get the same issue regardless.
Another post suggested the fix was to do this
heroku addons:add shared-database
Tried, get a message that shared-database is deprecated and to use heroku-postgresql, but that had no effect.
Thanks for any help
config HOST as localhost like :
'HOST': 'localhost',
The simplest(not comprehensive but one to get you up and running as quick as possible) solution to this error is, in your settings.py file , in the part where you have set up database settings revert the settings to
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
make migrations (i.e python manage.py makemigrations and then python manage.py migrate)
push your changes to GitHub, in your Heroku account, create a new app then move to the setting portion of your new app, connect to GitHub and deploy from GitHub, the database resources will then be provisioned for you (i.e a PostgreSQL database will be created with the same schema and data as your local SQLite database).