Skip to content
Snippets Groups Projects
Commit d6e76e6f authored by Pavel Vondruska's avatar Pavel Vondruska
Browse files

Uprava cli.go aby se kazde pouziti logovalo do syslogu kvuli statistikam

parent 149eb860
Branches
No related tags found
No related merge requests found
Pipeline #20683 passed
cli.go 0 → 100644
// Copyright (c) 2018-2021, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
package main
import (
"log"
"log/syslog"
"os"
"os/user"
"strings"
"fmt"
"github.com/sylabs/singularity/v4/cmd/internal/cli"
"github.com/sylabs/singularity/v4/internal/pkg/buildcfg"
useragent "github.com/sylabs/singularity/v4/pkg/util/user-agent"
)
func main() {
logger, err := syslog.New(syslog.LOG_INFO|syslog.LOG_USER, "singularity-start")
if err != nil {
log.Fatalf("Error while connecting to syslog: %v", err)
}
defer logger.Close()
currentUser, err := user.Current()
if err != nil {
currentUser = &user.User{Username: "unknown"}
}
hostname, err := os.Hostname()
if err != nil {
hostname = "unknown-host"
}
pbsJobID := os.Getenv("PBS_JOBID")
if pbsJobID == "" {
pbsJobID = "out-of-job"
}
cmd := os.Args[0]
args := strings.Join(os.Args[1:], " ")
message := fmt.Sprintf("%s@%s %s %s %s", currentUser.Username, hostname, pbsJobID, cmd, args)
logger.Info(message)
useragent.InitValue(buildcfg.PACKAGE_NAME, buildcfg.PACKAGE_VERSION)
// In cmd/internal/cli/singularity.go
cli.ExecuteSingularity()
}
...@@ -43,6 +43,7 @@ GOVERSION=${GOVERSION:-$(curl -s https://go.dev/VERSION?m=text | head -1)} ...@@ -43,6 +43,7 @@ GOVERSION=${GOVERSION:-$(curl -s https://go.dev/VERSION?m=text | head -1)}
# Priprava adresare pro hotove balicky a zapamatovani cesty # Priprava adresare pro hotove balicky a zapamatovani cesty
mkdir build mkdir build
export BUILD=${PWD}/build export BUILD=${PWD}/build
export ROOTPWD=${PWD}
# Stazeni a instalace GO # Stazeni a instalace GO
wget -q -O /tmp/${GOVERSION}.${OS}-${ARCH}.tar.gz https://dl.google.com/go/${GOVERSION}.${OS}-${ARCH}.tar.gz && tar -C /usr/local -xzf /tmp/${GOVERSION}.${OS}-${ARCH}.tar.gz wget -q -O /tmp/${GOVERSION}.${OS}-${ARCH}.tar.gz https://dl.google.com/go/${GOVERSION}.${OS}-${ARCH}.tar.gz && tar -C /usr/local -xzf /tmp/${GOVERSION}.${OS}-${ARCH}.tar.gz
...@@ -70,6 +71,9 @@ curl -LO https://proot.gitlab.io/proot/bin/proot ...@@ -70,6 +71,9 @@ curl -LO https://proot.gitlab.io/proot/bin/proot
chmod +x ./proot chmod +x ./proot
echo "proot usr/bin" >> debian/singularity-ce.install echo "proot usr/bin" >> debian/singularity-ce.install
# Kopie upraveneho cli.go kvuli logovani pouziti do syslogu
cp -v ${ROOTPWD}/cli.go cmd/singularity/cli.go
# Build balicku # Build balicku
dpkg-buildpackage -uc -us -b dpkg-buildpackage -uc -us -b
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment