Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ ARG PORT=8080
ENV ADDR=:$PORT
ARG USER=app

ENV IFACER_LOG="/log"
ENV IFACER_LOG="/app/proxy.log"

RUN addgroup --system "$USER" && adduser --system --ingroup "$USER" "$USER" && \
install -d -m 0755 -o "$USER" -g "$USER" /log
RUN addgroup --system "$USER" && adduser --system --ingroup "$USER" "$USER"

WORKDIR /app

COPY --from=builder /app/interfacer-proxy .
RUN chown app:app /app/interfacer-proxy

USER $USER

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ It can be started writing the `hosts.yaml` and running `make install` inside the
In the `hosts.yaml` one has to provide:
- `domain_name`: the FQDN of the server
- `zenflows`: URL for the zenflows instanc3
- `ifacer_log`: directory in which we want to save the logs
- `ifacer_log`: path to the log file
- `port`: port for proxy on `localhost`
- `here_api`: URL for the API of here.com
- `inbox_port`: port for inbox on `localhost`
Expand Down
4 changes: 2 additions & 2 deletions devops/roles/common/tasks/logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
---
- name: Create a directory if it does not exist
ansible.builtin.file:
path: "{{ ifacer_log }}"
path: "{{ ifacer_log | dirname }}"
state: directory
mode: '0755'
owner: root
Expand All @@ -32,7 +32,7 @@
dest: "/{{ basedir }}/.env.{{ port }}"
create: true
block: |
{{ ifacer_log }}* {
{{ ifacer_log }} {
size 100M
rotate 3
compress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ services:
WALLET_URL: "http://wallet"
INTERFACER_DPP_URL: "http://interfacer-dpp:8080"
OSH_URL: "http://osh/"
IFACER_LOG: "/log"
IFACER_LOG: "/app/proxy.log"
volumes:
- "{{ ifacer_log | dirname }}:/app"
extra_hosts:
- "gateway0.interfacer.dyne.org:10.202.41.10"
inbox:
Expand Down
13 changes: 9 additions & 4 deletions logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@
package logger

import (
"github.com/sirupsen/logrus"
"os"
"path/filepath"

"github.com/sirupsen/logrus"
)

var Log = logrus.New()

func InitLog(logPath string) {
func InitLog(logFile string) {
Log.SetFormatter(&logrus.JSONFormatter{})

Log.Out = os.Stdout

file, err := os.OpenFile(filepath.Join(logPath, "proxy.log"),
if logFile == "" {
Log.Info("Failed to log to file, using default stderr")
return
}

file, err := os.OpenFile(logFile,
os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
Log.WithFields(logrus.Fields{"err": err.Error()}).
Expand Down
15 changes: 11 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ import (
"bytes"
"errors"
"fmt"
"github.com/interfacerproject/interfacer-gateway/config"
"github.com/interfacerproject/interfacer-gateway/logger"
"github.com/sirupsen/logrus"
"io"
"log"
"net"
"net/http"
"net/url"
"os"
"time"

"github.com/interfacerproject/interfacer-gateway/config"
"github.com/interfacerproject/interfacer-gateway/logger"
"github.com/sirupsen/logrus"
)

var conf *config.Config
Expand Down Expand Up @@ -233,7 +235,12 @@ func (p *ProxiedHost) addHandle() (string, func(w http.ResponseWriter, r *http.R
}

func main() {
logger.InitLog(os.Getenv("IFACER_LOG"))
logFile, ok := os.LookupEnv("IFACER_LOG")
if !ok {
log.Printf(`"IFACER_LOG" was not provided; defaulting to "proxy.log"`)
logFile = "proxy.log"
}
logger.InitLog(logFile)

var err error
conf, err = config.NewEnv()
Expand Down