Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
bd1957bc
Commit
bd1957bc
authored
Dec 20, 2014
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spiceproxy: use PVE::Daemon
parent
f76dbc2d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
124 deletions
+68
-124
Makefile
bin/Makefile
+3
-0
spiceproxy
bin/init.d/spiceproxy
+25
-31
spiceproxy
bin/spiceproxy
+40
-93
No files found.
bin/Makefile
View file @
bd1957bc
...
...
@@ -46,6 +46,9 @@ all: ${MANS} pvemailforward
pvestatd.1.pod
:
pvestatd
perl
-I
.. ./pvestatd printmanpod
>
$@
spiceproxy.1.pod
:
spiceproxy
perl
-I
..
-T
./spiceproxy printmanpod
>
$@
pvectl.1.pod
:
pvectl
perl
-I
.. ./pvectl printmanpod
>
$@
...
...
bin/init.d/spiceproxy
View file @
bd1957bc
...
...
@@ -35,37 +35,31 @@ if [ -f /etc/default/$NAME ] ; then
fi
case
"
$1
"
in
start
)
log_daemon_msg
"Starting
$DESC
"
"
$NAME
"
start-stop-daemon
--start
--quiet
--pidfile
$PIDFILE
--exec
$DAEMON
--
${
DAEMON_OPTS
}
log_end_msg
$?
;;
stop
)
log_daemon_msg
"Stopping
$DESC
"
"
$NAME
"
start-stop-daemon
--stop
--quiet
--retry
TERM/2/TERM/15/KILL/2
--pidfile
$PIDFILE
log_end_msg
$?
;;
reload
)
log_daemon_msg
"Reloading
$DESC
"
"
$NAME
"
if
(
[
-e
$PIDFILE
]
&&
kill
-0
`
cat
$PIDFILE
`
)
then
start-stop-daemon
--stop
--signal
HUP
--pidfile
$PIDFILE
else
start-stop-daemon
--start
--quiet
--pidfile
$PIDFILE
--exec
$DAEMON
--
${
DAEMON_OPTS
}
fi
log_end_msg
$?
;;
restart|force-reload
)
log_daemon_msg
"Restarting
$DESC
"
"
$NAME
"
start-stop-daemon
--stop
--quiet
--retry
TERM/2/TERM/15/KILL/2
--pidfile
$PIDFILE
sleep
2
start-stop-daemon
--start
--quiet
--pidfile
$PIDFILE
--exec
$DAEMON
--
${
DAEMON_OPTS
}
log_end_msg
$?
;;
*
)
N
=
/etc/init.d/
$NAME
echo
"Usage:
$N
{start|stop|restart|force-reload}"
exit
1
;;
start
)
log_daemon_msg
"Starting
$DESC
"
"
$NAME
"
$DAEMON
start
log_end_msg
$?
;;
stop
)
log_daemon_msg
"Stopping
$DESC
"
"
$NAME
"
$DAEMON
stop
log_end_msg
$?
;;
reload
)
log_daemon_msg
"Reloading
$DESC
"
"
$NAME
"
$DAEMON
reload
log_end_msg
$?
;;
restart|force-reload
)
log_daemon_msg
"Restarting
$DESC
"
"
$NAME
"
$DAEMON
restart
log_end_msg
$?
;;
*
)
N
=
/etc/init.d/
$NAME
echo
"Usage:
$N
{start|stop|restart|force-reload}"
exit
1
;;
esac
exit
0
bin/spiceproxy
View file @
bd1957bc
...
...
@@ -11,31 +11,19 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
use
strict
;
use
warnings
;
use
English
;
use
Getopt::
Long
;
use
PVE::
SafeSyslog
;
use
PVE::
Daemon
;
use
PVE::
APIDaemon
;
use
PVE::
API2
;
my
$pidfile
=
"
/var/run/pveproxy/spiceproxy.pid
";
my
$lockfile
=
"
/var/lock/spiceproxy.lck
";
my
$opt_debug
;
initlog
('
spiceproxy
');
use
base
qw(PVE::Daemon)
;
if
(
!
GetOptions
('
debug
'
=>
\
$opt_debug
))
{
die
"
usage: $0 [--debug]
\n
";
}
my
$cmdline
=
[
$0
,
@ARGV
];
$SIG
{'
__WARN__
'}
=
sub
{
my
$err
=
$@
;
my
$t
=
$_
[
0
];
chomp
$t
;
syslog
('
warning
',
"
WARNING: %s
",
$t
);
$@
=
$err
;
};
my
%
daemon_options
=
(
restart_on_error
=>
5
,
stop_wait_time
=>
15
,
run_dir
=>
'
/var/run/pveproxy
');
$0
=
"
spiceproxy
"
;
my
$daemon
=
__PACKAGE__
->
new
('
spiceproxy
',
$cmdline
,
%
daemon_options
)
;
my
$gid
=
getgrnam
('
www-data
')
||
die
"
getgrnam failed - $!
\n
";
POSIX::
setgid
(
$gid
)
||
die
"
setgid
$gid
failed - $!
\n
";
...
...
@@ -46,81 +34,57 @@ POSIX::setuid($uid) || die "setuid $uid failed - $!\n";
# just to be sure
die
"
detected strange uid/gid
\n
"
if
!
(
$UID
==
$uid
&&
$EUID
==
$uid
&&
$GID
eq
"
$gid
$gid
"
&&
$EGID
eq
"
$gid
$gid
");
# we use same ALLOW/DENY/POLICY as pveproxy
my
$proxyconf
=
PVE::APIDaemon::
read_proxy_config
();
sub
init
{
my
(
$self
)
=
@_
;
# we use same ALLOW/DENY/POLICY as pveproxy
my
$proxyconf
=
PVE::APIDaemon::
read_proxy_config
();
my
$cpid
;
my
$daemon
;
eval
{
$daemon
=
PVE::
APIDaemon
->
new
(
$self
->
{
api_daemon
}
=
PVE::
APIDaemon
->
new
(
base_handler_class
=>
'
PVE::API2
',
port
=>
3128
,
keep_alive
=>
0
,
max_workers
=>
1
,
# do we need more?
max_conn
=>
500
,
lockfile
=>
$lockfile
,
debug
=>
$
opt_debug
,
lockfile
=>
"
/var/lock/spiceproxy.lck
"
,
debug
=>
$
self
->
{
debug
}
,
spiceproxy
=>
1
,
logfile
=>
'
/var/log/pveproxy/access.log
',
allow_from
=>
$proxyconf
->
{
ALLOW_FROM
},
deny_from
=>
$proxyconf
->
{
DENY_FROM
},
policy
=>
$proxyconf
->
{
POLICY
},
);
};
my
$err
=
$@
;
if
(
$err
)
{
syslog
('
err
'
,
"
unable to start server:
$err
");
print
STDERR
$err
;
exit
(
-
1
);
}
if
(
$opt_debug
||
!
(
$cpid
=
fork
()))
{
$SIG
{
PIPE
}
=
'
IGNORE
';
$SIG
{
INT
}
=
'
IGNORE
'
if
!
$opt_debug
;
$SIG
{
TERM
}
=
$SIG
{
QUIT
}
=
sub
{
syslog
('
info
'
,
"
server closing
");
$SIG
{
INT
}
=
'
DEFAULT
';
sub
shutdown
{
my
(
$self
)
=
@_
;
unlink
"
$pidfile
";
exit
(
0
);
};
syslog
('
info
'
,
"
starting server
");
if
(
!
$opt_debug
)
{
# redirect STDIN/STDOUT/SDTERR to /dev/null
open
STDIN
,
'
</dev/null
'
||
die
"
can't read /dev/null [$!]
";
open
STDOUT
,
'
>/dev/null
'
||
die
"
can't write /dev/null [$!]
";
open
STDERR
,
'
>&STDOUT
'
||
die
"
can't open STDERR to STDOUT [$!]
";
}
$self
->
exit_daemon
(
0
);
}
POSIX::
setsid
();
eval
{
$daemon
->
start_server
();
};
my
$err
=
$@
;
sub
run
{
my
(
$self
)
=
@_
;
$self
->
{
api_daemon
}
->
start_server
();
}
if
(
$err
)
{
syslog
('
err
'
,
"
unexpected server error:
$err
");
print
STDERR
$err
if
$opt_debug
;
exit
(
-
1
);
}
$daemon
->
register_start_command
(
__PACKAGE__
);
$daemon
->
register_restart_command
(
__PACKAGE__
,
0
);
$daemon
->
register_reload_command
(
__PACKAGE__
);
$daemon
->
register_stop_command
(
__PACKAGE__
);
$daemon
->
register_status_command
(
__PACKAGE__
);
my
$cmddef
=
{
start
=>
[
__PACKAGE__
,
'
start
',
[]
],
restart
=>
[
__PACKAGE__
,
'
restart
',
[]
],
reload
=>
[
__PACKAGE__
,
'
reload
',
[]
],
stop
=>
[
__PACKAGE__
,
'
stop
',
[]
],
status
=>
[
__PACKAGE__
,
'
status
',
[]
,
undef
,
sub
{
print
shift
.
"
\n
";}
],
};
}
else
{
my
$cmd
=
shift
;
open
(
PIDFILE
,
"
>
$pidfile
")
||
die
"
cant write '
$pidfile
' - $! :ERROR
";
print
PIDFILE
"
$cpid
\n
";
close
(
PIDFILE
)
||
die
"
cant write '
$pidfile
' - $! :ERROR
";
}
PVE::CLIHandler::
handle_cmd
(
$cmddef
,
$0
,
$cmd
,
\
@ARGV
,
undef
,
$0
);
exit
(
0
);
...
...
@@ -132,7 +96,7 @@ spiceproxy - SPICE proxy server for Proxmox VE
=head1 SYNOPSIS
spiceproxy [--debug]
=include synopsis
=head1 DESCRIPTION
...
...
@@ -147,21 +111,4 @@ from file /etc/default/pveproxy (see 'pveproxy' for details).
/etc/default/pveproxy
=head1 COPYRIGHT AND DISCLAIMER
Copyright (C) 2007-2013 Proxmox Server Solutions GmbH
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>.
=include pve_copyright
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