mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
Rework project structure
This commit is contained in:
@@ -4,15 +4,15 @@ import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/lus/pasty/internal/env"
|
||||
"github.com/lus/pasty/internal/config"
|
||||
"github.com/lus/pasty/internal/storage"
|
||||
"github.com/lus/pasty/internal/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Load the optional .env file
|
||||
log.Println("Loading the optional .env file...")
|
||||
env.Load()
|
||||
// Load the configuration
|
||||
log.Println("Loading the application configuration...")
|
||||
config.Load()
|
||||
|
||||
// Load the configured storage driver
|
||||
log.Println("Loading the configured storage driver...")
|
||||
@@ -29,7 +29,7 @@ func main() {
|
||||
}()
|
||||
|
||||
// Schedule the AutoDelete task
|
||||
if env.Bool("AUTODELETE", false) {
|
||||
if config.Current.AutoDelete.Enabled {
|
||||
log.Println("Scheduling the AutoDelete task...")
|
||||
go func() {
|
||||
for {
|
||||
@@ -41,7 +41,7 @@ func main() {
|
||||
log.Printf("AutoDelete: Deleted %d expired pastes", deleted)
|
||||
|
||||
// Wait until the process should repeat
|
||||
time.Sleep(env.Duration("AUTODELETE_TASK_INTERVAL", 5*time.Minute))
|
||||
time.Sleep(config.Current.AutoDelete.TaskInterval)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/lus/pasty/internal/env"
|
||||
"github.com/lus/pasty/internal/shared"
|
||||
"github.com/lus/pasty/internal/storage"
|
||||
)
|
||||
|
||||
@@ -12,7 +13,6 @@ func main() {
|
||||
// Validate the command line arguments
|
||||
if len(os.Args) != 3 {
|
||||
panic("Invalid command line arguments")
|
||||
return
|
||||
}
|
||||
|
||||
// Load the optional .env file
|
||||
@@ -20,7 +20,7 @@ func main() {
|
||||
env.Load()
|
||||
|
||||
// Create and initialize the first (from) driver
|
||||
from, err := storage.GetDriver(os.Args[1])
|
||||
from, err := storage.GetDriver(shared.StorageType(os.Args[1]))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -30,7 +30,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Create and initialize the second (to) driver
|
||||
to, err := storage.GetDriver(os.Args[2])
|
||||
to, err := storage.GetDriver(shared.StorageType(os.Args[2]))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user