Last active
April 18, 2017 20:34
-
-
Save notbrain/7077d2b999177047c3fa725288de3f8e to your computer and use it in GitHub Desktop.
plist file to run pm2 as pm2user on macOS with environment variables, linux systemd override.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Service] | |
Environment="MYSQL_CONN=-h mydb.domain.com -u dbadmin -pnotastrongpassword database_name" | |
Environment="SLACK_TOKEN=xoxb-94849484948-jfhJSdlobYIFfeFBFYHckiUUJHW19v0F" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.yourdomain.uniqueid</string> | |
<key>UserName</key> | |
<string>pm2user</string> | |
<key>KeepAlive</key> | |
<true/> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/bin/sh</string> | |
<string>-c</string> | |
<string>/usr/local/lib/node_modules/pm2/bin/pm2 resurrect</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>OnDemand</key> | |
<false/> | |
<key>LaunchOnlyOnce</key> | |
<true/> | |
<key>EnvironmentVariables</key> | |
<dict> | |
<key>PATH</key> | |
<string>/usr/local/Cellar/node@6/6.10.0_1/bin</string> | |
<key>PM2_HOME</key> | |
<string>/Users/notbrain/.pm2</string> | |
<key>MYSQL_CONN</key> | |
<string>-h mydb.domain.com -u dbadmin -pnotastrongpassword database_name</string> | |
<key>SLACK_TOKEN</key> | |
<string>xoxb-94849484948-jfhJSdlobYIFfeFBFYHckiUUJHW19v0F</string> | |
</dict> | |
<key>StandardErrorPath</key> | |
<string>/tmp/com.PM2.err</string> | |
<key>StandardOutPath</key> | |
<string>/tmp/com.PM2.out</string> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.plist
goes in~/Library/LaunchAgents/com.domain.pm2user.plist
.conf
file goes in/etc/systemd/system/pm2-pm2user.service.d/override.conf