Fix some errors, trivial problems.

This commit is contained in:
Naoki Kosaka 2021-06-19 07:30:32 +09:00
parent 0f59a6e5a1
commit 2ef9029bf0
4 changed files with 16 additions and 9 deletions

View File

@ -12,6 +12,7 @@ jobs:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Build Docker Images - name: Build Docker Images
run: | run: |
git fetch --prune --unshallow
docker build -t activity-relay:$(echo ${GITHUB_SHA}|head -c7) . docker build -t activity-relay:$(echo ${GITHUB_SHA}|head -c7) .
- name: Push Docker Images to DockerHub - name: Push Docker Images to DockerHub
run: | run: |

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"os" "os"
"strconv"
"github.com/RichardKnop/machinery/v1" "github.com/RichardKnop/machinery/v1"
"github.com/RichardKnop/machinery/v1/config" "github.com/RichardKnop/machinery/v1/config"
@ -36,13 +37,13 @@ func NewRelayConfig() (*RelayConfig, error) {
iconURL, err := url.ParseRequestURI(viper.GetString("RELAY_ICON")) iconURL, err := url.ParseRequestURI(viper.GetString("RELAY_ICON"))
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, "RELAY_ICON IS INVALID OR EMPTY. THIS COLUMN IS DISABLED.") fmt.Fprintln(os.Stderr, "RELAY_ICON: INVALID OR EMPTY. THIS COLUMN IS DISABLED.")
iconURL = nil iconURL = nil
} }
imageURL, err := url.ParseRequestURI(viper.GetString("RELAY_IMAGE")) imageURL, err := url.ParseRequestURI(viper.GetString("RELAY_IMAGE"))
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, "RELAY_IMAGE IS INVALID OR EMPTY. THIS COLUMN IS DISABLED.") fmt.Fprintln(os.Stderr, "RELAY_IMAGE: INVALID OR EMPTY. THIS COLUMN IS DISABLED.")
imageURL = nil imageURL = nil
} }
@ -117,11 +118,12 @@ func (relayConfig *RelayConfig) RedisClient() *redis.Client {
func (relayConfig *RelayConfig) DumpWelcomeMessage(moduleName string, version string) string { func (relayConfig *RelayConfig) DumpWelcomeMessage(moduleName string, version string) string {
return fmt.Sprintf(`Welcome to YUKIMOCHI Activity-Relay %s - %s return fmt.Sprintf(`Welcome to YUKIMOCHI Activity-Relay %s - %s
- Configuration - Configuration
RELAY NAME : %s RELAY NAME : %s
RELAY DOMAIN : %s RELAY DOMAIN : %s
REDIS URL : %s REDIS URL : %s
BIND ADDRESS : %s BIND ADDRESS : %s
`, version, moduleName, relayConfig.serviceName, relayConfig.domain.Host, relayConfig.redisURL, relayConfig.serverBind) JOB_CONCURRENCY : %s
`, version, moduleName, relayConfig.serviceName, relayConfig.domain.Host, relayConfig.redisURL, relayConfig.serverBind, strconv.Itoa(relayConfig.jobConcurrency))
} }
// NewMachineryServer create Redis backed Machinery Server from RelayConfig. // NewMachineryServer create Redis backed Machinery Server from RelayConfig.

View File

@ -4,6 +4,7 @@ import (
"crypto/rsa" "crypto/rsa"
"crypto/x509" "crypto/x509"
"encoding/pem" "encoding/pem"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -52,6 +53,9 @@ func readPrivateKeyRSA(keyPath string) (*rsa.PrivateKey, error) {
return nil, err return nil, err
} }
decoded, _ := pem.Decode(file) decoded, _ := pem.Decode(file)
if decoded == nil {
return nil, errors.New("ACTOR_PEM IS INVALID. FAILED TO READ")
}
privateKey, err := x509.ParsePKCS1PrivateKey(decoded.Bytes) privateKey, err := x509.ParsePKCS1PrivateKey(decoded.Bytes)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -13,8 +13,8 @@
- `github.com/yukimochi/Activity-Relay` - `github.com/yukimochi/Activity-Relay`
- `github.com/yukimochi/Activity-Relay/api` - `github.com/yukimochi/Activity-Relay/api`
- `github.com/yukimochi/Activity-Relay/deliver` - `github.com/yukimochi/Activity-Relay/deliver`
- `github.com/yukimochi/Activity-Relay/worker` - `github.com/yukimochi/Activity-Relay/control`
- `github.com/yukimochi/Activity-Relay/cli` - `github.com/yukimochi/Activity-Relay/models`
## Requirements ## Requirements