-
Notifications
You must be signed in to change notification settings - Fork 11
OSv Init
A host perform a few tasks when booting. The tasks falls into the following categories:
- Network configuration - static/dhcp, dns etc.
- Environment variable
- File and directory handling - directory creation and file deletion.
- Running the application - Running the actual application with their command line arguments
After the system is loaded, the following stages are done before running the application:
- Reading the local init file
- Optionally, downloading a remote cloud init file
- Start the API for external usage
- Run the applications
The OSV init is the responsible for the init tasks on the system boot. It reads the init file and starts additional applications.
It's also responsible for opening the API for external usage.
The OSv Init uses the API for most of its operations, it does not rely on TCP to connect to it, but would use a mediator class for direct calls. The OSv Init can use the API even if the httpserver will not run on the system.
When the OSv Init executes a configuration file, it can be marked as 'once' meaning that the file was executed. Execution requests to files marked as once will be ignored.
The Init file is a Yaml formatted file with instruction(s) to the the OSv Init. Among the commands in the file, there could be a read request to a remote Init file, which is a command to OSv Init itself.
Cloud init is a file that can be downloaded from a designated IP address. Cloud init in general can support multiple formats. On OSv, it uses YAML format. For details, see the Cloud init page on the OSv wiki.
The init configuration file compose of API calls. The file is in a Yaml format, and the commands are performed sequentially. Each command must have a GET, PUT, POST or DELETE instruction with the proper url.
# This is an example for a configuration file
# create a log directory
- PUT: /file/usr/log
op: MKDIRS
permission: 0777
- PUT: /env/path
value: usr/local/bin
# fetch remote file from a predetermined address
- GET: /include
host: 169.254.169.254
url: 2009-04-04/user-data
once: true
# echo to the screen
- GET: /shel/echo
message: Running the API
# open httpserver for input
- GET: /open-rest-api
# run an application
- PUT: /app/java.so
params: -jar myjar.jar