Commit db490bcd authored by Michael Hanus 's avatar Michael Hanus
Browse files

Analysis server extended by explicit port number argument

parent 7a7188a2
......@@ -11,8 +11,10 @@
module AnalysisServer(main,analyzeModuleForBrowser,analyzeGeneric,
analyzeInterface) where
import ReadNumeric(readNat)
import Char(isSpace)
import FlatCurry(QName)
import Socket(Socket(..),listenOnFresh,sClose,waitForSocketAccept)
import Socket(Socket(..),listenOn,listenOnFresh,sClose,waitForSocketAccept)
import IO
import ReadShowTerm(readQTerm,showQTerm)
import System(system,sleep,setEnviron,getArgs)
......@@ -39,29 +41,43 @@ main = do
debugMessageLevel 1 systemBanner
initializeSystem
args <- getArgs
if null args then mainServer else case args of
["-h"] -> showHelp
["-?"] -> showHelp
["--help"] -> showHelp
[ananame,modname] ->
analyzeModuleWithOutputFormat ananame modname "Text" True >>= putStrLn
_ -> error "Illegal arguments (use '--help' for description)"
if null args then mainServer Nothing else case args of
["-p",port] -> maybe showError
(\ (p,r) -> if all isSpace r
then mainServer (Just p)
else showError )
(readNat port)
["-h"] -> showHelp
["-?"] -> showHelp
["--help"] -> showHelp
[ananame,mname] ->
if ananame `elem` registeredAnalysisNames
then analyzeModuleWithOutputFormat ananame mname "Text" True >>= putStrLn
else showError
_ -> showError
where
showError = error "Illegal arguments (use '--help' for description)"
--- Initializations to be done when the system is started.
initializeSystem = updateRCFile
showHelp = putStrLn $
"Usage:\n"++
"cass : start analysis system in server mode\n\n"++
"cass <analysis name> <module name> :\n"++
"analyze a module with a given analysis\n\n"++
"Usage: cass [-p <port>] :\n" ++
" start analysis system in server mode\n\n"++
" <port>: port number for communication\n" ++
" (if omitted, a free port number is selected)\n\n"++
"Usage: cass <analysis name> <module name> :\n"++
" analyze a module with a given analysis\n\n"++
"Registered analyses names:\n" ++
unlines registeredAnalysisNames
--- Start server on a socket.
mainServer = do
mainServer :: Maybe Int -> IO ()
mainServer mbport = do
putStrLn "Start Server"
(port1,socket1) <- listenOnFresh
(port1,socket1) <- maybe listenOnFresh
(\p -> listenOn p >>= \s -> return (p,s))
mbport
putStrLn ("Server Port: "++show port1)
storeServerPortNumber port1
getDefaultPath >>= setEnviron "CURRYPATH"
......
......@@ -27,7 +27,7 @@ import Char(isSpace)
systemBanner =
let bannerText = "CASS: Curry Analysis Server System ("++
"version of 20/03/2013 for "++curryCompiler++")"
"version of 17/04/2013 for "++curryCompiler++")"
bannerLine = take (length bannerText) (repeat '=')
in bannerLine ++ "\n" ++ bannerText ++ "\n" ++ bannerLine
......
......@@ -4,8 +4,9 @@ CASS: The Curry Analysis Server System
This directory contains the implementation of CASS,
a generic and distributed analysis system for Curry programs.
The analysis system is structured as a client-server application
where the worker clients analyse individual modules.
The analysis system is structured as a worker/server application
where the workers are triggered by the main server to analyse
individual modules.
The analysis system can also be used as a client from other
application programs by a socket interface.
......@@ -13,22 +14,38 @@ The protocol of this interface is described in `Protocol.txt`.
The server is explicitly started by the program `cass`
(generated via `make`) or implicitly by application programs
that use of the operation `Configuration.getServerPortNumber`
to find out the port number to connect to the analysis server
(the port and process number of a running analysis server
are temporarily stored in the file `$HOME/.curryanalysis.port`).
to find out the port number to connect to the analysis server.
The port number can either be explicitly specified the starting
the main server program via
The program `cass` can also be started with arguments
(the analysis name and the name of the main module)
in order to analyze a module directly without the use
of the server protocol (run `cass --help` to get a description
of the arguments).
cass -p <port>
or a free port number is chosen when the analysis server is started.
The current port and process numbers of a running analysis server
are temporarily stored in the file `$HOME/.curryanalysis.port`
(in the tuple format `(port,pid)`).
The program `cass` can also be started on a console with arguments:
cass <analysis> <module>
In this case, the analysis with the specified name is applied
to the specified module without the use of the server protocol
and the output is shown on stdout. Run the command
cass --help
to get a description of the arguments and a list of registered analysis
names.
The analysis system can be configured in the file `$HOME/.curryanalysisrc`
which is installed after the first run of the system.
The implementations of the individual analysis are
usually stored in the directory `analysis`.
usually stored in a separate directory (here: `../analysis`).
Description of some Curry files:
--------------------------------
* `AnalysisCollection`: All available analyses must be registered here.
* `Analysis`: Base type to define an analysis.
......@@ -39,4 +56,4 @@ Description of some Curry files:
dependency analyses, see option `fixpoint` in the configuration file,
must be inserted here).
Contact: Michael Hanus (www.informatik.uni-kiel.de/~mh)
Contact: [Michael Hanus](http://www.informatik.uni-kiel.de/~mh)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment