Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. [Unit]
  2. Description=Keeps a tunnel to 'remote.example.com' open
  3. After=network.target
  4.  
  5. [Service]
  6. User=autossh
  7. # -p [PORT]
  8. # -l [user]
  9. # -M 0 --> no monitoring
  10. # -N Just open the connection and do nothing (not interactive)
  11. # LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM
  12. ExecStart=/usr/bin/autossh -M 0 -N -q -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -p 22 -l autossh remote.example.com -L 7474:127.0.0.1:7474 -i /home/autossh/.ssh/id_rsa
  13.  
  14. [Install]
  15. WantedBy=multi-user.target
  16.  
  17. [Unit]
  18. Description=AutoSSH service for ServiceABC on %i
  19. After=network.target
  20.  
  21. [Service]
  22. Environment=AUTOSSH_GATETIME=30 AUTOSSH_LOGFILE=/var/log/autossh/%i.log AUTOSSH_PIDFILE=/var/run/autossh.%i.pid
  23. PIDFile=/var/run/autossh.%i.pid
  24. #Type=forking
  25. ExecStart=/usr/bin/autossh -M 40000 -NR 5000:127.0.0.1:5000 -i /opt/ServiceABC/.ssh/id_rsa_ServiceABC -l ServiceABC %i
  26.  
  27. [Install]
  28. WantedBy=multi-user.target
  29.  
  30. [user@anotherhost ~]$ sudo systemctl enable autossh@somehost.example.com
  31. ln -s '/etc/systemd/system/autossh@.service' '/etc/systemd/system/multi-user.target.wants/autossh@somehost.example.com.service'
  32.  
  33. [user@anotherhost ~]$ sudo systemctl start autossh@somehost.example.com
  34. [user@anotherhost ~]$ sudo systemctl status autossh@somehost.example.com
  35. autossh@somehost.example.service - AutoSSH service for ServiceABC on somehost.example
  36. Loaded: loaded (/etc/systemd/system/autossh@.service; enabled)
  37. Active: active (running) since Tue 2015-10-20 13:19:01 EDT; 17s ago
  38. Main PID: 32524 (autossh)
  39. CGroup: /system.slice/system-autossh.slice/autossh@somehost.example.com.service
  40. ├─32524 /usr/bin/autossh -M 40000 -NR 5000:127.0.0.1:5000 -i /opt/ServiceABC/.ssh/id_rsa_ServiceABC -l ServiceABC somehost.example.com
  41. └─32525 /usr/bin/ssh -L 40000:127.0.0.1:40000 -R 40000:127.0.0.1:40001 -NR 5000:127.0.0.1:5000 -i /opt/ServiceABC/.ssh/id_rsa_ServiceABC -l ServiceABC somehost.example.com
  42.  
  43. Oct 20 13:19:01 anotherhost.example.com systemd[1]: Started AutoSSH service for ServiceABC on somehost.example.com.
  44. [user@anotherhost ~]$ sudo systemctl status autossh@somehost.example.com
  45. [user@anotherhost ~]$ sudo systemctl status autossh@somehost.example.com
  46. autossh@somehost.example.com.service - AutoSSH service for ServiceABC on somehost.example.com
  47. Loaded: loaded (/etc/systemd/system/autossh@.service; enabled)
  48. Active: inactive (dead) since Tue 2015-10-20 13:24:10 EDT; 2s ago
  49. Process: 32524 ExecStart=/usr/bin/autossh -M 40000 -NR 5000:127.0.0.1:5000 -i /opt/ServiceABC/.ssh/id_rsa_ServiceABC -l ServiceABC %i (code=exited, status=0/SUCCESS)
  50. Main PID: 32524 (code=exited, status=0/SUCCESS)
  51.  
  52. Oct 20 13:19:01 anotherhost.example.com systemd[1]: Started AutoSSH service for ServiceABC on somehost.example.com.
  53. Oct 20 13:24:10 anotherhost.example.com systemd[1]: Stopping AutoSSH service for ServiceABC on somehost.example.com...
  54. Oct 20 13:24:10 anotherhost.example.com systemd[1]: Stopped AutoSSH service for ServiceABC on somehost.example.com.
  55.  
  56. [Unit]
  57. Description=az gearman worker
  58. After=gearman-job-server.service
  59.  
  60. [Service]
  61. PIDFile=/var/run/gearman_worker_az%i.pid
  62. Type=simple
  63. User=www-data
  64. WorkingDirectory=/var/www/mysite.com/jobs/
  65. ExecStart=/usr/bin/php -f gearman_worker_az.php > /dev/null 2>&1
  66. Restart=on-success
  67. KillMode=process
  68.  
  69. [Install]
  70. WantedBy=multi-user.target
  71.  
  72. [Unit]
  73. Description=manages my worker service, instance %i
  74. After=multi-user.target
  75.  
  76. [Service]
  77. PermissionsStartOnly=true
  78. Type=idle
  79. User=root
  80. ExecStart=/usr/local/virtualenvs/bin/python /path/to/my/script.py
  81. Restart=always
  82. TimeoutStartSec=10
  83. RestartSec=10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement