Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
nfpm release test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrostami committed Apr 12, 2020
1 parent 973ad40 commit 90e0a34
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 10 deletions.
141 changes: 141 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,144 @@ builds:
id: gcrond
main: ./cmd/gcrond/
binary: gcrond

nfpms:
# note that this is an array of nfpm configs
-
# ID of the nfpm config, must be unique.
# Defaults to "default".
id: gcrond

# Name of the package.
# Defaults to `ProjectName`.
package_name: gcrond

# You can change the file name of the package.
# Default: `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}`
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

# Build IDs for the builds you want to create NFPM packages for.
# Defaults to all builds.
builds:
- gcrond

# Replacements for GOOS and GOARCH in the package name.
# Keys should be valid GOOSs or GOARCHs.
# Values are the respective replacements.
# Default is empty.
replacements:
amd64: 64-bit
386: 32-bit
darwin: macOS
linux: Tux

# Your app's vendor.
# Default is empty.
# vendor: Drum Roll Inc.

# Your app's homepage.
# Default is empty.
# homepage: https://example.com/

# Your app's maintainer (probably you).
# Default is empty.
maintainer: Mo <[email protected]>

# Your app's description.
# Default is empty.
description: Software to execute a bash command with extra features

# Your app's license.
# Default is empty.
license: MIT

# Formats to be generated.
formats:
- deb
- rpm

# Packages your package depends on.
dependencies:
- bash

# Packages your package recommends installing.
recommends:
- npm

# Packages your package suggests installing.
# suggests:
# - cvs
# - ksh

# Packages that conflict with your package.
# conflicts:
# - svn
# - bash

# Override default /usr/local/bin destination for binaries
bindir: /usr/local/bin

# Package epoch.
# Defaults to empty.
epoch: 1

# Package release.
# Defaults to empty.
release: 1

# Empty folders that should be created and managed by the packager
# implementation.
# Default is empty.
empty_folders:
- /var/log/gcron/
- /etc/gcron/
- /var/www/gcron/web/static

# Files to add to your package (beyond the binary).
# Keys are source paths/globs to get the files from.
# Values are the destination locations of the files in the package.
# Use globs to add all contents of a folder.
files:
"web/static/globs": "/var/www/gcron/web/static"
# "scripts/etc/init.d/**": "/etc/init.d"

# Config files to add to your package. They are about the same as
# the files keyword, except package managers treat them differently (while
# uninstalling, mostly).
# Keys are source paths/globs to get the files from.
# Values are the destination locations of the files in the package.
config_files:
"configs/gcrond_pkg.yml": "/etc/gcron/gcrond.yml"

# Scripts to execute during the installation of the package.
# Keys are the possible targets during the installation process
# Values are the paths to the scripts which will be executed
# scripts:
# preinstall: "scripts/preinstall.sh"
# postinstall: "scripts/postinstall.sh"
# preremove: "scripts/preremove.sh"
# postremove: "scripts/postremove.sh"

# Some attributes can be overrided per package format.
# overrides:
# deb:
# conflicts:
# - subversion
# dependencies:
# - git
# suggests:
# - gitk
# recommends:
# - tig
# empty_folders:
# - /var/log/bar
# rpm:
# replacements:
# amd64: x86_64
# name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Arch }}"
# files:
# "tmp/man.gz": "/usr/share/man/man8/app.8.gz"
# config_files:
# "tmp/app_generated.conf": "/etc/app-rpm.conf"
# scripts:
# preinstall: "scripts/preinstall-rpm.sh"
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ gcron -c="echo Server1HelloWorld" --server.rpc.enable --lock.enable --lock.remot

# Screenshots
#### Main Page
![Main Page](./assets/MainPage.png)
![Main page](./assets/MainPage.png)
#### Task Duration Graph
![Task duration](./assets/CommandGraph.png)
#### Task Details
![Task Page](./assets/CommandPage.png)

![Task info](./assets/CommandPage.png)

## TODO

Expand Down Expand Up @@ -163,7 +164,7 @@ gcron -c="echo Server1HelloWorld" --server.rpc.enable --lock.enable --lock.remot
- [ ] Support different clients (syslog, ...)
- [ ] Fix casts int32 to int or int64 to int32
- [ ] Live reloading config file

- [ ] MakeFile

## FIXME
- Delete local lock file
Expand Down
3 changes: 2 additions & 1 deletion configs/gcrond.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ server:
log:
enable: false
level: "info"
path: "/var/log/gcron/gcron-server.log"
path: "/var/log/gcron/gcrond.log"

web:
static: "web/static"
auth:
user: "admin"
pass: "admin"
19 changes: 19 additions & 0 deletions configs/gcrond_pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

server:
web:
host: "localhost"
port: "1401"
rpc:
host: "localhost"
port: "1400"

log:
enable: false
level: "info"
path: "/var/log/gcron/gcrond.log"

web:
static: "/var/www/gcron/web/static"
auth:
user: "admin"
pass: "admin"
10 changes: 6 additions & 4 deletions web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import (
// Listen start web server
func Listen(db db.DB, cfg config.GeneralConfig) {
// gin.DefaultWriter = log.StandardLogger().Writer()
staticPath := cfg.GetKey("web.static").(string)

r := gin.Default()
t, _ := loadTemplate()
t, _ := loadTemplate(staticPath)
r.SetHTMLTemplate(t)

r.Use(sessions.Sessions("mysession", sessions.NewCookieStore([]byte("secret"))))
Expand All @@ -34,7 +36,7 @@ func Listen(db db.DB, cfg config.GeneralConfig) {
authUser := cfg.GetKey("web.auth.user").(string)
authPath := cfg.GetKey("web.auth.pass").(string)
addPublicPage(r, pages.NewLoginPage(authUser, authPath))
r.Use(static.Serve("/", static.LocalFile("web/static/public", false)))
r.Use(static.Serve("/", static.LocalFile(staticPath+"/public", false)))
authorized := r.Group("/")
authorized.Use(authRequired)
{
Expand Down Expand Up @@ -74,7 +76,7 @@ func addRouterPage(r *gin.RouterGroup, page pages.Page) {
}
}

func loadTemplate() (*template.Template, error) {
func loadTemplate(staticPath string) (*template.Template, error) {
t := template.New("")
t.Funcs(template.FuncMap{
"byteToString": func(value []byte) template.HTML {
Expand Down Expand Up @@ -128,6 +130,6 @@ func loadTemplate() (*template.Template, error) {
return fmt.Sprintf("%.2f", value)
},
})
_, err := t.ParseGlob("web/static/*.tmpl")
_, err := t.ParseGlob(staticPath + "/*.tmpl")
return t, err
}
2 changes: 1 addition & 1 deletion web/static/public/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var path = require('path');

module.exports = {
mode: 'development',
mode: 'production',
entry: './app/index.js',
output: {
filename: 'bundle.js',
Expand Down

0 comments on commit 90e0a34

Please sign in to comment.