Skip to content

Commit

Permalink
Listen on port 8081 by default instead of 80
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferry Boender committed Apr 19, 2017
1 parent 58d79a1 commit 9c3fde0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ Set some rights and create the initial `htpasswd` file:

We can now start ScriptForm to start serving the form over HTTP. By default it
starts as a daemon, so we specify the `-f` option to start it in the foreground
instead.
instead. We also specify the port, even though 8081 is already the default.

$ scriptform -f -p8080 ./test_server.json
$ scriptform -f -p8081 ./test_server.json

The user is presented with the following form:

Expand Down Expand Up @@ -197,15 +197,15 @@ ScriptForm can run both in daemon mode or in the foreground. In daemon mode, we
can control ScriptForm with the `--start` and `--stop` options. By default it
runs on port 80, which we can change with the `-p` option.

$ ./scriptform -p8000 ./test_server.json
$ ./scriptform -p8081 ./test_server.json

This puts ScriptForm in the background as a daemon. It creates a PID file and a
log file.

$ tail scriptform.py.log
2015-04-08 07:57:27,160:DAEMON:INFO:Starting
2015-04-08 07:57:27,161:DAEMON:INFO:PID = 5614
2015-04-08 07:57:27,162:SCRIPTFORM:INFO:Listening on 0.0.0.0:8000
2015-04-08 07:57:27,162:SCRIPTFORM:INFO:Listening on 0.0.0.0:8081

In order to stop the daemon:

Expand Down
2 changes: 1 addition & 1 deletion contrib/scriptform.init.d_debian
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PIDFILE=/var/run/scriptform.pid
LOGFILE=/var/log/scriptform.log
DAEMON=/usr/bin/scriptform
FORM_CONFIG=
PORT=8080
PORT=8081
DAEMON_ARGS="--port $PORT --pid-file $PIDFILE --log-file $LOGFILE $FORM_CONFIG"

# Define LSB log_* functions.
Expand Down
2 changes: 1 addition & 1 deletion contrib/scriptform.init.d_redhat
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PIDFILE=/var/run/scriptform.pid
LOGFILE=/var/log/scriptform.log
DAEMON=/usr/bin/scriptform
FORM_CONFIG=
PORT=8080
PORT=8081
DAEMON_ARGS="--port $PORT --pid-file $PIDFILE --log-file $LOGFILE $FORM_CONFIG"

start() {
Expand Down
22 changes: 11 additions & 11 deletions doc/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ production ready.
Sriptform can be run directly from the shell in the foreground with the `-f`
(`--foreground`) option. This is most useful for testing and development:

$ /usr/bin/scriptform -p8000 -f ./formdef.json
$ /usr/bin/scriptform -p8081 -f ./formdef.json

You can specify the `-r` option to automatically reload the JSON file upon each
request:

$ /usr/bin/scriptform -p8000 -r -f ./formdef.json
$ /usr/bin/scriptform -p8081 -r -f ./formdef.json

### <a name="invocations_daemon">Daemon</a>

If you do not specify the `-f` option, Scriptform will go into the background:

$ /usr/bin/scriptform -p8000 ./formdef.json
$ /usr/bin/scriptform -p8081 ./formdef.json
$

A pid file will be written in the current directory, or to the file specified
Expand Down Expand Up @@ -260,8 +260,8 @@ Enable Apache modules mod_proxy and mod_proxy_http:
Configure:

Redirect permanent /scriptform /scriptform/
ProxyPass /scriptform/ http://localhost:8000/
ProxyPassReverse /scriptform/ http://localhost:8000/
ProxyPass /scriptform/ http://localhost:8081/
ProxyPassReverse /scriptform/ http://localhost:8081/

Make sure the path ends in a slash! (That's what the redirect is for).
Otherwise, you may encounter the following error:
Expand Down Expand Up @@ -336,10 +336,10 @@ Fix the permisions so it is executable:

Now start Scriptform with our newly created form configuration file:

$ scriptform -p8000 -f -r ./sf_tutorial.json
$ scriptform -p8081 -f -r ./sf_tutorial.json

This starts the built-in webserver which will serve the form on port 8000. When
you open it in your browser (http://127.0.0.1:8000/) you will immediately see
This starts the built-in webserver which will serve the form on port 8081. When
you open it in your browser (http://127.0.0.1:8081/) you will immediately see
the form. If we had multiple forms in this form configuration, you would first
see a list of all the forms.

Expand Down Expand Up @@ -378,7 +378,7 @@ Now modify the `job_sysinfo.sh` script to output HTML instead of plain text:
<pre>$DISK</pre>
END_OF_TEXT

Open http://127.0.0.1:8000 in your browser and submit the form. That looks a
Open http://127.0.0.1:8081 in your browser and submit the form. That looks a
little better, doesn't it? The `html` output type lets you embed HTML in the
output of the script. The default output type is `escaped`, which escaped any
HTML and just outputs plain text wrapped in a Scriptform response header and
Expand Down Expand Up @@ -441,9 +441,9 @@ Make it executable:
And start Scriptform (not required if it's still running and you're using the
same .json file):

$ scriptform -p8000 -f -r ./sf_tutorial.json
$ scriptform -p8081 -f -r ./sf_tutorial.json

Point your browser to http://127.0.0.01:8000. Try submitting the form with and
Point your browser to http://127.0.0.01:8081. Try submitting the form with and
without entering a name.

As you can see, Scriptform makes form values available to scripts through the
Expand Down
4 changes: 2 additions & 2 deletions src/scriptform.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def get_form_config(self):
self.form_config_singleton = form_config
return form_config

def run(self, listen_addr='0.0.0.0', listen_port=80):
def run(self, listen_addr='0.0.0.0', listen_port=8081):
"""
Start the webserver on address `listen_addr` and port `listen_port`.
This call is blocking until the user hits Ctrl-c, the shutdown() method
Expand Down Expand Up @@ -187,7 +187,7 @@ def main(): # pragma: no cover
action="store_true", default=False,
help="Generate password")
parser.add_option("-p", "--port", dest="port", action="store", type="int",
default=80, help="Port to listen on (default=80)")
default=8081, help="Port to listen on (default=8081)")
parser.add_option("-f", "--foreground", dest="foreground",
action="store_true", default=False,
help="Run in foreground (debugging)")
Expand Down

0 comments on commit 9c3fde0

Please sign in to comment.