Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fcb6204a
authored
Apr 22, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update system log
parent
bc88176d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
34 deletions
+13
-34
common/init.go
+12
-33
main.go
+1
-1
No files found.
common/init.go
View file @
fcb6204a
...
@@ -11,19 +11,16 @@ import (
...
@@ -11,19 +11,16 @@ import (
var
(
var
(
Port
=
flag
.
Int
(
"port"
,
3000
,
"the listening port"
)
Port
=
flag
.
Int
(
"port"
,
3000
,
"the listening port"
)
PrintVersion
=
flag
.
Bool
(
"version"
,
false
,
"print version and exit"
)
PrintVersion
=
flag
.
Bool
(
"version"
,
false
,
"print version and exit"
)
PrintHelp
=
flag
.
Bool
(
"help"
,
false
,
"print help and exit"
)
LogDir
=
flag
.
String
(
"log-dir"
,
""
,
"specify the log directory"
)
LogDir
=
flag
.
String
(
"log-dir"
,
""
,
"specify the log directory"
)
//Host = flag.String("host", "localhost", "the server's ip address or domain")
//Path = flag.String("path", "", "specify a local path to public")
//VideoPath = flag.String("video", "", "specify a video folder to public")
//NoBrowser = flag.Bool("no-browser", false, "open browser or not")
)
)
// UploadPath Maybe override by ENV_VAR
func
printHelp
()
{
var
UploadPath
=
"upload"
fmt
.
Println
(
"One API "
+
Version
+
" - All in one API service for OpenAI API."
)
fmt
.
Println
(
"Copyright (C) 2023 JustSong. All rights reserved."
)
//var ExplorerRootPath = UploadPath
fmt
.
Println
(
"GitHub: https://github.com/songquanpeng/one-api"
)
//var ImageUploadPath = "upload/images"
fmt
.
Println
(
"Usage: one-api [--port <port>] [--log-dir <log directory>] [--version] [--help]"
)
//var VideoServePath = "upload"
}
func
init
()
{
func
init
()
{
flag
.
Parse
()
flag
.
Parse
()
...
@@ -33,18 +30,17 @@ func init() {
...
@@ -33,18 +30,17 @@ func init() {
os
.
Exit
(
0
)
os
.
Exit
(
0
)
}
}
if
*
PrintHelp
{
printHelp
()
os
.
Exit
(
0
)
}
if
os
.
Getenv
(
"SESSION_SECRET"
)
!=
""
{
if
os
.
Getenv
(
"SESSION_SECRET"
)
!=
""
{
SessionSecret
=
os
.
Getenv
(
"SESSION_SECRET"
)
SessionSecret
=
os
.
Getenv
(
"SESSION_SECRET"
)
}
}
if
os
.
Getenv
(
"SQLITE_PATH"
)
!=
""
{
if
os
.
Getenv
(
"SQLITE_PATH"
)
!=
""
{
SQLitePath
=
os
.
Getenv
(
"SQLITE_PATH"
)
SQLitePath
=
os
.
Getenv
(
"SQLITE_PATH"
)
}
}
if
os
.
Getenv
(
"UPLOAD_PATH"
)
!=
""
{
UploadPath
=
os
.
Getenv
(
"UPLOAD_PATH"
)
//ExplorerRootPath = UploadPath
//ImageUploadPath = path.Join(UploadPath, "images")
//VideoServePath = UploadPath
}
if
*
LogDir
!=
""
{
if
*
LogDir
!=
""
{
var
err
error
var
err
error
*
LogDir
,
err
=
filepath
.
Abs
(
*
LogDir
)
*
LogDir
,
err
=
filepath
.
Abs
(
*
LogDir
)
...
@@ -58,21 +54,4 @@ func init() {
...
@@ -58,21 +54,4 @@ func init() {
}
}
}
}
}
}
//if *Path != "" {
// ExplorerRootPath = *Path
//}
//if *VideoPath != "" {
// VideoServePath = *VideoPath
//}
//
//ExplorerRootPath, _ = filepath.Abs(ExplorerRootPath)
//VideoServePath, _ = filepath.Abs(VideoServePath)
//ImageUploadPath, _ = filepath.Abs(ImageUploadPath)
//
if
_
,
err
:=
os
.
Stat
(
UploadPath
);
os
.
IsNotExist
(
err
)
{
_
=
os
.
Mkdir
(
UploadPath
,
0777
)
}
//if _, err := os.Stat(ImageUploadPath); os.IsNotExist(err) {
// _ = os.Mkdir(ImageUploadPath, 0777)
//}
}
}
main.go
View file @
fcb6204a
...
@@ -24,7 +24,7 @@ var indexPage []byte
...
@@ -24,7 +24,7 @@ var indexPage []byte
func
main
()
{
func
main
()
{
common
.
SetupGinLog
()
common
.
SetupGinLog
()
common
.
SysLog
(
"
system
started"
)
common
.
SysLog
(
"
One API "
+
common
.
Version
+
"
started"
)
if
os
.
Getenv
(
"GIN_MODE"
)
!=
"debug"
{
if
os
.
Getenv
(
"GIN_MODE"
)
!=
"debug"
{
gin
.
SetMode
(
gin
.
ReleaseMode
)
gin
.
SetMode
(
gin
.
ReleaseMode
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment