ejabberd how to compile new module - erlang

Here I found the code:
erlc -I ~/ejabberd-2.1.13/lib/ejabberd-2.1.13/include -pa ~/ejabberd-2.1.13/lib/ejabberd-2.1.13/ebin mod_my.erl
But it did not work?

Here are steps to add your custom module into ejabberd
put your module into ejabberd/src folder.
come to ejabberd directory in terminal and run command $ sudo make
it will show you that your module is compiled. Now run $ sudo make install
Add your module into config file at /etc/ejabberd/ejabberd.yml
restart your ejabberd and your custom module will be running.

These are the Instructions based on Ejabberd recommendation
1) Form the folder structure like below (refer any module from --
https://github.com/processone/ejabberd-contrib).
sources
│
│───conf
│ └───modulename.yml
│───src
│ └───modulename.erl
│───README.txt
│───COPYING
│───modulename.spec
2) Add your module folder structure to ejabberd user home directory (check ejabberdctl.cfg for CONTRIB_MODULES_PATH param).
3) Type command ejabberdctl modules_available it will list your module
4) Type ejabberdctl module_install module_name command
For Reference https://docs.ejabberd.im/developer/extending-ejabberd/modules/

Just drop the module in the ejabberd's src/ folder then "make". Nothing special needed to compile it.

Related

How to install the locate command on nixos

I've searched on the nixos package manager, if there is package named locate.
Yes and several. But that's not the bash command that I am searching for.
I want to add this bash command
locate name.extention
which gave me the path of this file
The package mlocate provides a locate executable. The package plocate provides an executable named plocate which might be better. Both of these packages will require some extra setup steps to allow them to build their file location database, and I don't happen to have a link to those instructions at the moment.
nix-shell -p mlocate

AWX - Could not find imported module support code for version

i installed AWX and can run my playbooks. But for some reasons i get this Error-Message when i want to run my Playbook where the community.docker module is in the tasks.
I get the Error Message:
fatal: [local]: FAILED! => {"msg": "Could not find imported module support code for version. Looked for either StrictVersion.py or version.py"}
I installed the module on my awx container (task and web) and also in my virtualenv. But nothing helped.
When i run the Playbook via ansible-playbook command it works fine.
Does anyone know an answer or a solution? thanks
There is a way you can install a collection in your project repository.
├── collections/
you can create above directory in your project where you have parent / trigger playbooks and install docker collection in it using below command.
ansible-galaxy collection install community.docker -p collections
This will allow you to install maintain and update required collections at project level.

I am not able to open the Django admin file

Whenever I start a new Django project using:
(virtual) C:\myDjangoProject>python django_admin.py startproject DjgoProject
I receive the following error:
python: can't open file 'django_admin.py': [Errno 2] No such file or directory
Any guidance please?
If you have created a virtual environment (which it looks like you have) and then run:
pip install django
Then you shouldn't need to run django-admin directly like that, you can just do the following:
django-admin startproject DjgoProject

How do I run a python file in Atom? Conda env?

I don't quite know what to do. I use VSCode and Jupyter Notebook and conda env. I just downloaded Atom and it keeps saying no kernal for grammar python. I have a similar problem if I try using the conda command in Terminal where it doesn't recognize the conda command until I:
export PATH=/Users/edgar/anaconda3/bin:$PATH
How do I make my atom run my python code? Thank you very much.
to set up atom to become a python ide you need packages like:
Community Packages (14) /home/simone/.atom/packages
├── Hydrogen#2.14.1
├── atom-ide-ui#0.13.0
├── autocomplete-python#1.16.0
├── hydrogen-python#0.0.8
├── ide-python#1.5.0
├── intentions#1.1.5
├── linter#2.3.1 (disabled)
├── linter-flake8#2.4.0
├── linter-ui-default#1.8.1
└── python-autopep8#0.1.3
and to run atom on a conda / pyenv environment you just need to:
$ cd [path to project]
$ conda activate [env]
$ atom .
so that atom will use that python env to run the scripts.
The easiest way is to install the package script. Then open the python script you want to run and go to the packages menu in the menu bar. Under this menu, you should see an option - Script. Select "script" and one option is to run the python script. Select this option and your python file should run. You can also tap the F5 key. That will also run your file.
This assumes you have the package "language-python" installed in Atom. If you dont you can get it from here.

How to install Golang package locally that's referenced as a github.com address

I have a package that I'm referencing in my Go code as:
github.com/apache/pulsar/pulsar-function-go/pf
However, I need to include some local changes to that library when building a docker image for setting up an integration test.
In my Dockerfile, I've setup GOPATH and GOROOT and PATH like this:
ENV GOROOT /usr/local/go
ENV GOPATH /go
ENV PATH /go/bin:$PATH
Then, in the Dockerfile, I copy the source code into my Docker image and attempt to install the Go module, like this:
COPY target/pulsar-function-go/ /pulsar/dependencies/pulsar-function-go/
RUN cd /pulsar/dependencies/pulsar-function-go/pf && go install .
However, when I then try to build a file that references github.com/apache/pulsar/pulsar-function-go/pf by running this line:
RUN go build -o /pulsar/examples/go-examples/exclamationFunc /pulsar/examples/go-examples/exclamationFunc.go
I get this exception message:
---> Running in bb3ec43f7fea
examples/go-examples/exclamationFunc.go:24:2: cannot find package
"github.com/apache/pulsar/pulsar-function-go/pf" in any of:
/usr/local/go/src/github.com/apache/pulsar/pulsar-function-go/pf (from
$GOROOT)
/go/src/github.com/apache/pulsar/pulsar-function-go/pf (from $GOPATH)
Is there a way to allow me to use a locally installed version of that same package without needing to change the reference in the code that I'm trying to build?
EDIT Here's everything else I've tried:
When I run go install in pulsar-function-go, I get:
cannot find module for path .
When I run go install in pulsar-function-go/pf, I get:
examples/go-examples/exclamationFunc.go:24:2: cannot find package "github.com/apache/pulsar/pulsar-function-go/pf" in any of:
/usr/local/go/src/github.com/apache/pulsar/pulsar-function-go/pf (from $GOROOT)
/go/src/github.com/apache/pulsar/pulsar-function-go/pf (from $GOPATH)
When I try running:
RUN go get -t github.com/apache/pulsar/pulsar-function-go/...
(although this won’t bring in my local changes, it was just for testing)
I get:
# github.com/apache/pulsar/pulsar-function-go/examples/test
/go/src/github.com/apache/pulsar/pulsar-function-go/examples/test/producer.go:30:6: main redeclared in this block
previous declaration at /go/src/github.com/apache/pulsar/pulsar-function-go/examples/test/consumer.go:30:6
# github.com/apache/pulsar/pulsar-function-go/examples
/go/src/github.com/apache/pulsar/pulsar-function-go/examples/hello.go:32:6: main redeclared in this block
previous declaration at /go/src/github.com/apache/pulsar/pulsar-function-go/examples/contextFunc.go:36:6
/go/src/github.com/apache/pulsar/pulsar-function-go/examples/inputFunc.go:34:6: main redeclared in this block
previous declaration at /go/src/github.com/apache/pulsar/pulsar-function-go/examples/hello.go:32:6
/go/src/github.com/apache/pulsar/pulsar-function-go/examples/outputFunc.go:33:6: main redeclared in this block
previous declaration at /go/src/github.com/apache/pulsar/pulsar-function-go/examples/inputFunc.go:34:6
When I try running:
RUN go get -t github.com/apache/pulsar/pulsar-function-go
I get:
package github.com/apache/pulsar/pulsar-function-go: no Go files in /go/src/github.com/apache/pulsar/pulsar-function-go
If I try running this to first get some of the dependencies:
RUN go get -t github.com/apache/pulsar/pulsar-function-go/pf
it succeeds. If I then follow that in my Dockerfile with:
# after using Maven plugin to copy files from the pulsar-function-go source directory to target/pulsar-function-go
COPY target/pulsar-function-go/ /go/src/github.com/apache/pulsar/pulsar-function-go
RUN cd /go/src/github.com/apache/pulsar/pulsar-function-go/pf && go install
to replace the source code for pulsar-function-go in the docker file with my local code, then when I try to build the binary, like this:
RUN go build -o /pulsar/examples/go-examples/exclamationFunc /pulsar/examples/go-examples/exclamationFunc.go
I get:
/go/src/github.com/apache/pulsar/pulsar-function-go/pb/InstanceCommunication.pb.go:29:2: cannot find package "google.golang.org/grpc" in any of:
/usr/local/go/src/google.golang.org/grpc (from $GOROOT)
/go/src/google.golang.org/grpc (from $GOPATH)
/go/src/github.com/apache/pulsar/pulsar-function-go/pb/InstanceCommunication.pb.go:30:2: cannot find package "google.golang.org/grpc/codes" in any of:
/usr/local/go/src/google.golang.org/grpc/codes (from $GOROOT)
/go/src/google.golang.org/grpc/codes (from $GOPATH)
/go/src/github.com/apache/pulsar/pulsar-function-go/pb/InstanceCommunication.pb.go:31:2: cannot find package "google.golang.org/grpc/status" in any of:
/usr/local/go/src/google.golang.org/grpc/status (from $GOROOT)
/go/src/google.golang.org/grpc/status (from $GOPATH)
12:13
The google.golang.org/grpc package is included in the go.mod file, which looks like this:
module github.com/apache/pulsar/pulsar-function-go
go 1.13
require (
github.com/apache/pulsar-client-go v0.0.0-20200116214305-4d788d9935ed
github.com/golang/protobuf v1.3.2
github.com/sirupsen/logrus v1.4.1
github.com/stretchr/testify v1.3.0
golang.org/x/tools v0.0.0-20200119215504-eb0d8dd85bcc // indirect
google.golang.org/grpc v1.26.0
gopkg.in/yaml.v2 v2.2.2
)
From the answer below, I was told that I can insert a replace directive in the Go module to allow us to point to local files when I build the Go binaries for the tests.
However, I don’t think I’m able to install the module correctly, perhaps due to the way the pulsar-function-go/examples are included in the module.
So, I can't figure out what to set as the /local/path/to/package because I can't install the package successfully. (Maybe I'm confused about this too?)
Is there a better way that we could structure the module/code to enable the installation of the local pulsar-function-go module into the test Docker image?
If you want to look at the Go code yourself, see it here: https://github.com/apache/pulsar/tree/master/pulsar-function-go
The Dockerfile is here: https://github.com/apache/pulsar/blob/master/tests/docker-images/latest-version-image/Dockerfile
Use go modules for your project, and include a replace directive in it for the package you're referencing to:
replace github.com/apache/pulsar/pulsar-function-go/pf => /local/path/to/package

Resources