Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dummyhttpserver
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yoshiharu Hirose
dummyhttpserver
Commits
bcc80266
Commit
bcc80266
authored
May 02, 2016
by
Yoshiharu Hirose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
待ち受け失敗時、他のポートだけでも起動する。
parent
33e4876d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
DummyHttpServer.scala
src/main/scala/DummyHttpServer.scala
+10
-3
No files found.
src/main/scala/DummyHttpServer.scala
View file @
bcc80266
...
@@ -22,19 +22,26 @@ object DummyHttpServer {
...
@@ -22,19 +22,26 @@ object DummyHttpServer {
}
}
val
basedirOps
=
Option
(
if
(
args
.
length
>
0
)
args
(
0
)
else
properties
.
getProperty
(
"basedir"
))
val
basedirOps
=
Option
(
if
(
args
.
length
>
0
)
args
(
0
)
else
properties
.
getProperty
(
"basedir"
))
println
(
"Base directory: "
+
basedirOps
.
get
)
val
portsOps
=
Option
(
properties
.
getProperty
(
"ports"
)).
map
(
_
.
split
(
","
).
map
(
_
.
toInt
)).
getOrElse
(
DEFAULT_PORTS
)
val
portsOps
=
Option
(
properties
.
getProperty
(
"ports"
)).
map
(
_
.
split
(
","
).
map
(
_
.
toInt
)).
getOrElse
(
DEFAULT_PORTS
)
for
(
basedir
<-
basedirOps
;
port
<-
portsOps
)
{
for
(
basedir
<-
basedirOps
;
port
<-
portsOps
)
{
printf
(
"Starting server. basedir: %s, port: %d\n"
,
basedir
,
port
)
try
{
startServer
(
basedir
,
port
)
startHttpServer
(
basedir
,
port
)
printf
(
"Starting HTTP server at port %d\n"
,
port
)
}
catch
{
case
e
:
IOException
=>
printf
(
"Failed to start HTTP server at port %d: %s\n"
,
port
,
e
.
getMessage
)
}
}
}
}
}
/**
/**
* サーバ起動
* サーバ起動
*
*
* @param basedir ベースディレクトリ
* @param port 待ち受けポート番号
* @param port 待ち受けポート番号
*/
*/
def
startServer
(
basedir
:
String
,
port
:
Int
)
{
def
start
Http
Server
(
basedir
:
String
,
port
:
Int
)
{
val
server
=
HttpServer
.
create
(
new
InetSocketAddress
(
port
),
10
)
val
server
=
HttpServer
.
create
(
new
InetSocketAddress
(
port
),
10
)
server
.
createContext
(
"/"
,
new
DummyHttpServer
.
MyHandler
(
basedir
))
server
.
createContext
(
"/"
,
new
DummyHttpServer
.
MyHandler
(
basedir
))
server
.
start
()
server
.
start
()
...
...
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