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 web
andmicro api
, if your service requires othermicro
products 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
micro
together with the respective unit files:This installs thesudo make install
web
andapi
commands. See the Install outcome section for next steps.
To run the build, you need:
-
make
installed, 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 get
to 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 api
andmicro web
run:Amake build commands="api web"
micro
executable is created atbin/micro
while the respective unit files are created inside theunit
directory - 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