IPFS Start ipfs daemon direct from the go application

Hi everyone

I am developing an application in Go that uses IPFS to add files and to send messages through pubsub feature.
I would like to start the daemon directly from the go application. I had tried calling a bash file with the following commands

if [ ! -e ${HOME}/.ipfs/api ]
then
_ ipfs daemon --enable-pubsub-experiment &_
else
_ echo ā€œIPFS already startedā€_
fi
while [ ! -e ${HOME}/.ipfs/api ]
do
_ echo ā€œWaiting for IPFS to startā€;_
_ sleep 1_
done

but it had not working.

Someone know a library that I can use in go to start the daemon directly from the application?

Thanks in advance
Diana

Hi @dserna,

Iā€™m interested in this question as well.

My current approach is to understand go-ipfs/cmd/ipfs which ā€œimplements the primary CLI binary for ipfs.ā€

There should be a way to starting the daemon, i.e., the API server. :grinning:

Tomorrow I will work on it and post my findings.

Cu, Stefan

Hi @dserna,

I did it. Have a look https://github.com/stefanhans/go-ipfs-play/tree/master/daemon

My next approach will be to import "syscall" and use it to check for ipfs daemon

cu, Stefan

Have a look https://github.com/stefanhans/go-ipfs-play/tree/master/ipfs-daemon-start

Hi @stefanhans65

Thanks a lot :hugs:
I had tested the example https://github.com/stefanhans/go-ipfs-play/tree/master/ipfs-daemon-start
and it works perfect, I had modified the line 19 to:
cmd.Args = []string{ā€œipfsā€, ā€œdaemonā€, ā€œā€“enable-pubsub-experimentā€}
because I am working with the experimental feature pubsub and it works fineā€¦

I had also find one example to start the ipfs daemon using the syscall (for Raspbian Stretch, Ubuntu 15.04 and newer, CentOS 7 and newer):


** Note: you will need to change the line Environment=IPFS_PATH={{ipfs_path}} with you enviroment path

I had used it to start the ipfs daemon by boot in a raspberry and beaglebone and it works fine.

Thanks again for your help

Diana

Hi @dserna,

you are very welcome :grinning:

BTW: What API do you use? Iā€™m playing around with these two currently:


Cheers, Stefan

:wave: Found out you are using ā€˜go-ipfs-api.ā€™ The ā€˜unofficialā€™ in the README title makes me consider the ā€˜interface-go-ipfs-core.ā€™ :thinking:

Hi @stefanhans65

I had installed go-ipfs, since I am using different machines I had installed the go-ipfs v0.4.19 linux binary arm (for an arm machine with linux), the bare bones IPFS installer for Raspberry from claudiobizzotto and updated it to the version 0.4.19

I have written some applications in Go to work with IPFS and they are using the go-ipfs-api, but I guess after to read the README I will try with the interface-go-ipfs-core :roll_eyes:

about the ipfs-daemon.service.tpl
you should create this file in the folder /lib/systemd/system
to enable you can use the following command: systemctl enable ipfs-daemon

systemctl {disable|status|start|stop} ipfs-daemon

Liebe GrĆ¼ĆŸe
Diana

Hi @dserna,

youā€™ve probably seen my posting

Letā€™s see :grinning:

Liebe GrĆ¼ĆŸe aus MĆ¼nchen

Stefan

1 Like