Skip to content

Commit cf8898f

Browse files
committed
Merge pull request #212 from sbt/wip/getting-started-guide-additions
Wip/getting started guide additions
2 parents 6759179 + 986ee3b commit cf8898f

File tree

5 files changed

+203
-1
lines changed

5 files changed

+203
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
Adding configuration
2+
####################
3+
4+
After :doc:`creating a package <MyFirstProject>`, the very next thing needed, usually, is the ability for users/ops to customize the application once it's deployed. Let's add some configuration to the newly deployed application.
5+
6+
There are generally two types of configurations:
7+
8+
* Configuring the JVM and the process
9+
* Configuring the Application itself.
10+
11+
The server archetype provides you with a special feature to configure your application
12+
with a single file. As this file is OS dependend, each OS gets section.
13+
14+
Linux
15+
*****
16+
17+
Create ``src/templates/etc-default`` with the following template
18+
19+
.. code-block :: bash
20+
21+
# Available replacements
22+
# ------------------------------------------------
23+
# ${{author}} debian author
24+
# ${{descr}} debian package description
25+
# ${{exec}} startup script name
26+
# ${{chdir}} app directory
27+
# ${{retries}} retries for startup
28+
# ${{retryTimeout}} retry timeout
29+
# ${{app_name}} normalized app name
30+
# ${{daemon_user}} daemon user
31+
# -------------------------------------------------
32+
33+
# Setting -Xmx and -Xms in Megabyte
34+
# -mem 1024
35+
36+
# Setting -X directly (-J is stripped)
37+
# -J-X
38+
# -J-Xmx1024
39+
40+
# Add additional jvm parameters
41+
# -Dkey=val
42+
43+
# For play applications you may set
44+
# -Dpidfile.path=/var/run/${{app_name}}/play.pid
45+
46+
# Turn on JVM debugging, open at the given port
47+
# -jvm-debug <port>
48+
49+
# Don't run the java version check
50+
# -no-version-check
51+
52+
# enabling debug and sending -d as app argument
53+
# the '--' prevents app-parameter swalloing when
54+
# using a reserved parameter. See #184
55+
# -d -- -d
56+
57+
The file will be installed to ``/etc/default/<normalizedName>`` and read from there
58+
by the startscript.
59+
60+
Environment variables
61+
=====================
62+
63+
The usual ``JAVA_OPTS`` can be used to override settings. This is a nice way to test
64+
different jvm settings with just restarting the jvm.
65+
66+
Windows
67+
*****
68+
69+
Support planned for 0.8.0
70+
71+
Example Configurations
72+
######################
73+
74+
A list of very small configuration settings can be found at `sbt-native-packager-examples`_
75+
76+
.. _sbt-native-packager-examples: https://github.com/muuki88/sbt-native-packager-examples
77+
78+
Next, let's :doc:`how to override start templates <OverrdingTemplates>`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
My First Packaged Server Project
2+
################################
3+
4+
Follow the instructions for the basic ``java_application`` setup in :doc:`../GettingStartedApplications/index` to get a working build and
5+
understand the core concepts of sbt-native-packager. Based on this configuration we exchange
6+
in our ``build.sbt``
7+
8+
.. code-block:: scala
9+
10+
packageArchetype.java_application
11+
12+
with
13+
14+
.. code-block:: scala
15+
16+
packageArchetype.java_server
17+
18+
19+
which will activate all server specific settings. As the server settings are dependent
20+
on which OS your using the following sections will provide details for each supported
21+
OS.
22+
23+
Linux
24+
*****
25+
26+
A basic ``build.sbt`` for the supported ``rpm`` and ``deb`` packaging systems
27+
require the following information:
28+
29+
.. code-block:: scala
30+
31+
maintainer in Linux := "John Smith <[email protected]>"
32+
33+
packageSummary in Linux := "A small package summary"
34+
35+
packageDescription := "A longer description of your application"
36+
37+
38+
There are additional parameters available to configure.
39+
40+
.. code-block:: scala
41+
42+
daemonUser in Linux := normalizedName.value // user which will execute the application
43+
44+
daemonGroup in Linux := daemonUser.value // group which will execute the application
45+
46+
47+
Debian (.deb)
48+
=============
49+
50+
A basic ``build.sbt`` for debian requires only the Linuxs settings. You can build your
51+
server application with
52+
53+
::
54+
55+
debian:packageBin
56+
57+
58+
Ubuntu provides two different bootsystems, SystemV and Upstart (default). To switch between
59+
both you can add this to your ``build.sbt``
60+
61+
.. code-block:: scala
62+
63+
import com.typesafe.sbt.packager.archetypes.ServerLoader.{SystemV, Upstart}
64+
65+
serverLoading in Debian := SystemV
66+
67+
RPM (.rpm)
68+
==========
69+
70+
A basic ``build.sbt`` for rpm requires the Linuxs settings and
71+
72+
.. code-block:: scala
73+
74+
rpmVendor := "Your organization Inc."
75+
76+
Build your rpm package with ::
77+
78+
rpm:packageBin
79+
80+
The output is partially on ``stderr`` which is a bit confusing. If the build
81+
ends with *success* you are fine.
82+
83+
Windows
84+
*******
85+
86+
Planned for 0.8.0
87+
88+
Next, let's look at how to :doc:`Add configuration files <AddingConfiguration>` to use with our script.
89+
90+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Overriding templates
2+
####################
3+
4+
This works the same way as for the standard application type. Read more on :doc:`../GettingStartedApplications/OverridingTemplates`
5+

src/sphinx/GettingStartedServers/index.rst

+23
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,26 @@ Currently the native package supports the following installation targets for ser
2525
| Windows | Windows Services | |
2626
+---------------+--------------------+-----------+
2727

28+
What is a Server Archetype
29+
==========================
30+
31+
A server project extends the basic ``java_application`` with some server specific features,
32+
which are currently on
33+
34+
Linux
35+
~~~~~
36+
37+
* ``/var/log/<pkg>`` is symlinked from ``<install-location>/log``
38+
39+
* ``/var/run/<pkg>`` is created with write privileges for the ``daemonUser``
40+
41+
* ``/etc/<pkg>`` is symlinked from ``<install-location>/conf``
42+
43+
* Creates a start script in ``/etc/init.d`` (SystemV) or ``/etc/init/`` (Upstart)
44+
45+
* Creates a startup config file in ``/etc/default/<pkg>``
46+
47+
48+
Next, let's :doc:`get started with simple application <MyFirstProject>`
49+
50+

src/sphinx/conf.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# serve to show the default.
1313

1414
import sys, os
15+
import sphinx_bootstrap_theme
1516

1617
# If extensions (or modules to document with autodoc) are in another directory,
1718
# add these directories to sys.path here. If the directory is relative to the
@@ -91,15 +92,20 @@
9192

9293
# The theme to use for HTML and HTML Help pages. See the documentation for
9394
# a list of builtin themes.
94-
html_theme = 'sphinxdoc'
95+
html_theme = 'bootstrap'
9596

9697
# Theme options are theme-specific and customize the look and feel of a theme
9798
# further. For a list of options available for each theme, see the
9899
# documentation.
99100
#html_theme_options = {}
101+
html_theme_options = {
102+
'bootstrap_version': "3",
103+
'bootswatch_theme': "yeti",
104+
}
100105

101106
# Add any paths that contain custom themes here, relative to this directory.
102107
#html_theme_path = []
108+
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
103109

104110
# The name for this set of Sphinx documents. If None, it defaults to
105111
# "<project> v<release> documentation".

0 commit comments

Comments
 (0)