Docker image rgitzel/mqttwarn additional python functions not working
See original GitHub issueHi to everybody,
first of all I want to thank @rgitzel for the usefull and really complete image for mqttwarn. I need to use mqttwarn functionalities in order to feed a carbon (whisper) db from messages subscribed on a mqtt broker for my project.
I’ve included rgitzel image mqttwarn-full as a service within a docker-compose file in order to be used to build up my solution.
The docker-compose.yml
file part (regarding your image) is the following:
mqttwarn-full:
container_name: mqttwarn
restart: always
image: rgitzel/mqttwarn-full
volumes:
- '/opt/mqttwarn/conf:/opt/mqttwarn/conf'
- '/opt/mqttwarn/log/mqttwarn.log:/opt/mqttwarn/mqttwarn.log'
- '/opt/mqttwarn/functions:/opt/mqttwarn/functions'
environment:
USER_ID: '998' # UID of the docker_user I've created to run the container
GROUP_ID: '997' # GID of the docker_user I've created to run the container
I’ve so create the mqttwarn.ini
file within the host folder /opt/mqttwarn/conf
and put a custom python function called my_carbon.py
within the host folder /opt/mqttwarn/functions
. Note: I’ve also set the permission on that folders (and on all the files within it) to the docker_user accordingly to what I’ve defined within the environment variables section of the docker-compose.yml
above (UID:998 and GID:997).
As suggested I’ve include in the mqttwarn.ini file above the name of my custom python function.
Below the part of the mqttwarn.ini
file (in bold the integration I’ve made in order to be able to use the new python function).
; path to file containing self-defined functions for formatmap and datamap
#functions = 'samplefuncs.py'
functions = 'functions/my_carbon.py'
; name the service providers you will be using.
launch = file, log, carbon, my_carbon
[config:my_carbon]
targets = {
'c1' : [ 'graphite_statsd', 2003 ],
}
[APA0/iIPdubgSRi/#]
targets = my_carbon:c1, log:debug, log:error
When I ran the docker-compose I get the following error in the log of mqttwarn:
2020-05-03 13:25:06,211 INFO [mqttwarn] Starting mqttwarn
2020-05-03 13:25:06,211 INFO [mqttwarn] Log level is DEBUG
2020-05-03 13:25:06,216 DEBUG [mqttwarn] Service file loaded
2020-05-03 13:25:06,217 DEBUG [mqttwarn] Service log loaded
2020-05-03 13:25:06,218 DEBUG [mqttwarn] Service carbon loaded
2020-05-03 13:25:06,218 ERROR [mqttwarn] Can't load my_carbon service (services/my_carbon.py): [Errno 2] No such file or directory: u'services/my_carbon.py'
It seems to me that the mqttwarn.py
process is searching for the my_carbon.py
function file within the default python function folder (that is called services and that is within the container)
instead of searching it within the functions folder that I’ve crated in the host system and where I’ve put the my_carbon.py
file.
I’m also sure that the bind mount of the volume I’ve defined within the docker-compose.yml
file with the command below:
- '/opt/mqttwarn/functions:/opt/mqttwarn/functions'
I’m sure is working correctly because I can “see” the content of this folder either from the container (entering with exec command) and from the host system…
I’m literally going crazy in order to understand how can I solve it… Can someone please help me in some way?
Thanks a lot in advanced for any help you should give me!!
Leonardo
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (8 by maintainers)
Top GitHub Comments
I’m using an custom function with cron, and at least on windows host it worked fine here…
Here is my docker-compose:
Apologies, and thanks for reminding me, @koenvervloesem. I have pushed
0.15.1-1
to the hub.