-
Notifications
You must be signed in to change notification settings - Fork 170
/
emailengine.service
97 lines (72 loc) · 3.13 KB
/
emailengine.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Example systemd unit file for EmailEngine
# Requires Node.js and Redis
# Installation instructions for Node.js:
# https://nodejs.org/en/download/package-manager/
# Install Redis on Ubuntu:
# https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04
# Copy this file to /etc/systemd/system/emailengine.service
# Once set up (or service file is modified) run as root:
# systemctl daemon-reload
# systemctl enable emailengine
# systemctl restart emailengine
[Unit]
Description=EmailEngine
# In some platforms redis could be installed as redis-server.service
# So make sure the service name listed here is valid
After=redis.service
[Service]
Environment="NODE_ENV=production"
# --- Configuration ---
# Optional. Uncomment to use a system specific configuration file outside of the EmailEngine folder.
# Configuration settings from this file are merged with default settings.
#Environment="NODE_CONFIG_PATH=/etc/emailengine.toml"
# Optional. Uncomment to override configuration values with environment variables
#Environment="EENGINE_REDIS=redis://127.0.0.1:6379/8"
#Environment="EENGINE_HOST=127.0.0.1"
#Environment="EENGINE_PORT=3000"
#Environment="EENGINE_LOG_LEVEL=trace"
# --- Application ---
# This is the folder where EmailEngine files reside.
# NB! If you are using `npx` to run the application then you can ignore this section
# and comment out `WorkingDirectory` as npx manages code files and dependencies itself.
# Normally this folder would include a clean copy from the EmailEngine Github repository + `npm install --omit=dev`.
# To set up:
# git clone git://github.com/postalsys/emailengine.git
# cd emailengine
# npm install --omit=dev
# If EmailEngine files are cloned from Github then an easy way to upgrade the application would look like this:
# git pull origin master
# npm install --omit=dev
# And then (as root or a user with sudo privileges):
# sudo systemctl restart emailengine
WorkingDirectory=/home/deployer/apps/emailengine/
# --- Service user ---
# Use non-privileged user to run the app.
# www-data usually already exists in the system but could be any other user as well.
# Make sure this user has read access to application files and, if using
# config file at $NODE_CONFIG_PATH, then to this file as well
User=www-data
Group=www-data
# --- Execution ---
# npm location is dependent on platform.
# Use `which npm` to resolve actual path.
ExecStart=/usr/bin/npm start
# Alternatively you can use `npx` instead of `npm`. This way you would not have to
# manage application files or dependencies manually. For upgrading, just modify
# application version in the following command and run `systemctl daemon-reload && systemctl restart emailengine`
# NB! First start after version change is going to take some time as `npx` has to install all dependencies.
#ExecStart=/usr/bin/npx emailengine@1.2.14
Type=simple
Restart=always
RestartSec=5
# Increse limits
# file size, ulimit -f
LimitFSIZE=infinity
# open files, ulimit -n
LimitNOFILE=500000
# processes/threads, ulimit -u
LimitNPROC=500000
# --- Logging ---
SyslogIdentifier=emailengine
[Install]
WantedBy=multi-user.target