I have created a small golang API (nrfapi) which include a config.toml file. I would like to deploy the api on other ubuntu VM therefore i build the API using the "GOOS=linux GOARCH=amd64 go build" and then scp the build file to the VM /var/www/go diretory. I also create a unit file (nrf.service) ending in .service within the /etc/systemd/system directory. In the .service file i have the following configuration
[Unit] Description= instance to serve nrf api After=network.target [Service] User=root Group=www-data ExecStart=/var/www/go/nrfapi) [Install] WantedBy=multi-user.target
Error ● nrf.service - instance to serve nrf api Loaded: loaded (/etc/systemd/system/nrf.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2019-03-30 16:44:51 EET; 11s ago Main PID: 4066 (code=exited, status=1/FAILURE) Mar 30 16:44:51 ubuntu systemd: Started instance to serve nrf api. Mar 30 16:44:51 ubuntu nrfapi: 2019/03/30 16:44:51 open config.toml: no such file or directory Mar 30 16:44:51 ubuntu systemd: nrf.service: Main process exited, code=exited, status=1/FAILURE Mar 30 16:44:51 ubuntu systemd: nrf.service: Unit entered failed state. Mar 30 16:44:51 ubuntu systemd: nrf.service: Failed with result 'exit-code'.
However, after starting the API using the following commands
sudo systemctl start nrfapi sudo systemctl enable nrfapi
the API is not running. I realize from the error message above that the API need the config.toml file configurations.
My problem now is that i dont know which directory to place the config.toml file so that the golang api can read the configuration parameters from there. Can anyone help me solve this? How do i go about this?