Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
golang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Bogdan Ungureanu
golang
Commits
7e1d16cf
Commit
7e1d16cf
authored
Jul 02, 2014
by
Bogdan Ungureanu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Permision denied for daemon pid file
parent
fe0ade8e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
daemon.go
os/daemon/daemon.go
+22
-3
No files found.
os/daemon/daemon.go
View file @
7e1d16cf
...
@@ -85,7 +85,10 @@ func (d *Daemon) Run() error {
...
@@ -85,7 +85,10 @@ func (d *Daemon) Run() error {
if
d
.
startServer
||
d
.
restartServer
{
if
d
.
startServer
||
d
.
restartServer
{
if
pid
:=
d
.
getPid
();
pid
==
0
{
if
pid
:=
d
.
getPid
();
pid
==
0
{
d
.
startProcess
()
err
:=
d
.
startProcess
()
if
err
!=
nil
{
return
err
}
os
.
Exit
(
0
)
os
.
Exit
(
0
)
}
}
return
errors
.
New
(
"Process allready running"
)
return
errors
.
New
(
"Process allready running"
)
...
@@ -111,7 +114,11 @@ func (d *Daemon) Run() error {
...
@@ -111,7 +114,11 @@ func (d *Daemon) Run() error {
// Read pid from file , check if process is running
// Read pid from file , check if process is running
func
(
d
*
Daemon
)
getPid
()
int
{
func
(
d
*
Daemon
)
getPid
()
int
{
var
pid
int
var
pid
int
f
,
err
:=
os
.
Open
(
d
.
PidFile
)
f
,
err
:=
os
.
OpenFile
(
d
.
PidFile
,
os
.
O_RDONLY
,
0666
,
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
return
0
}
}
...
@@ -182,6 +189,17 @@ func (d *Daemon) startProcess() error {
...
@@ -182,6 +189,17 @@ func (d *Daemon) startProcess() error {
procArgs
:=
[]
string
{}
procArgs
:=
[]
string
{}
opt
:=
""
opt
:=
""
// Test if we can create pid file
pidfile
,
err
:=
os
.
OpenFile
(
d
.
PidFile
,
os
.
O_CREATE
|
os
.
O_RDWR
,
0666
,
)
if
err
!=
nil
{
return
err
}
pidfile
.
Close
()
for
_
,
arg
:=
range
d
.
args
{
for
_
,
arg
:=
range
d
.
args
{
if
strings
.
HasPrefix
(
arg
,
"-"
)
{
if
strings
.
HasPrefix
(
arg
,
"-"
)
{
opt
=
arg
opt
=
arg
...
@@ -199,9 +217,10 @@ func (d *Daemon) startProcess() error {
...
@@ -199,9 +217,10 @@ func (d *Daemon) startProcess() error {
Dir
:
procPath
,
Dir
:
procPath
,
Env
:
env
,
Env
:
env
,
Files
:
[]
*
os
.
File
{
nil
,
nil
,
nil
},
Files
:
[]
*
os
.
File
{
nil
,
nil
,
nil
},
//Files: []*os.File{os.Stdin, os.Stdout, os.Stderr},
}
}
_
,
err
:
=
os
.
StartProcess
(
procName
,
procArgs
,
procAttr
)
_
,
err
=
os
.
StartProcess
(
procName
,
procArgs
,
procAttr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
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