An auto-installer of micro as a service in systemd systems.
There are two approaches to install:
-
Install pre-compiled micro binary (straight forward approach)
Notes:
- Most services can safely use this approach.
- This is not guaranteed to use the latest version of micro as it uses a precompiled binary.
- The installer installs
micro webandmicro api, if your service requires othermicroproducts then it's best to use the build and install approach - this gives you more options.
-
Build and install the latest release of the micro binary (you will need to have the go compiler installed to achieve this approach)
To run the build, you need make installed, easiest way to install this is:
sudo apt install build-essential
- Clone the repository and cd into it
git clone https://github.com/tomogoma/micro-installer cd micro-installer - Install
microtogether with the respective unit files:This installs thesudo make installwebandapicommands. See the Install outcome section for next steps.
To run the build, you need:
-
makeinstalled, easiest way to install this is:sudo apt install build-essential -
a fully set up go runtime and working GOPATH. Instructions here: https://golang.org/doc/install
This is because the build scripts use
go getto fetch the micro repository, checkout the latest release branch and build an executable to be installed. SystemD unit files are also created for the micro commands provided during build.
- Clone the repository and cd into it
git clone https://github.com/tomogoma/micro-installer cd micro-installer - Build the installer.
Build the installer with the micro commands you wish to have unit files for
e.g. to build for
micro apiandmicro webrun:Amake build commands="api web"microexecutable is created atbin/microwhile the respective unit files are created inside theunitdirectory - Install the build outcome:
This installs the commands provided during the build step. See the Install outcome section for next steps.
sudo make install
systemctl start micro[command].service
e.g.
systemctl start microapi.service
systemctl stop micro[command].service
systemctl status micro[command].service
The micro binary is installed into
/usr/local/bin/micro
Systemd service unit files are created at
/etc/systemd/system/micro[command].service
the command micro --help or micro [command] --help provides all configuration options
applicable.
To change config values for a command e.g. change listening address, append the relevant environment
variable to /etc/systemd/system/micro[command].service
e.g.
[Service]
Environment=MICRO_API_ADDRESS=0.0.0.0:8089 "ANOTHER_ENV_VAR=some value"
...
Once done, perform a daemon reload for changes to take effect:
systemctl daemon-reload
cd /path/to/micro-installer
sudo make uninstall