melezhik / service

Manages Linux services
1 stars 1 forks source link

add Archlinux support and simple test #1

Closed spigell closed 7 years ago

spigell commented 7 years ago

Здравствуйте. Добавил поддержку archlinux в скрипт. Так как в этой ОС нет обратной совместимостью с SysV, то немного изменил start/stop модули. Добавил простой тест. Не совсем уверен, что так лучше. Возможно, стоит размещать по ОС их. Можете попробовать его так (находясь в корневой директории)

sudo strun --root ./.tests --ini ./.tests/dev.suite.ini

Проверял на archlinux и centos7. Ошибок не было.

spigell commented 7 years ago

Добавил sparrowfile с примером.

melezhik commented 7 years ago

успешно проверил на моем примере

$ cat sparrowfile 
my $service = 'nginx';

set_spl %( service-dev => 'https://github.com/melezhik/service.git' );

package-install ('openssl','nginx');

task-run 'disable $service service', 'service-dev', %(
  service => $service,
  action  => 'disable',
);

task-run 'stopping $service service', 'service-dev', %(
  service => $service,
  action  => 'stop'
);

task-run 'starting $service service', 'service-dev', %(
  service => $service,
  action  => 'start'
);

task-run 'enable $service service', 'service-dev', %(
  service => $service,
  action  => 'enable'
);

$ sparrowdo --ssh_port=2222 --ssh_user=vagrant --ssh_private_key=/home/melezhik/projects/vboxes/archlinux/.vagrant/machines/default/virtualbox/private_key   
running sparrow tasks on 127.0.0.1 ... 
target OS is - archlinux
push service-dev https://github.com/melezhik/service.git into SPL - OK
push [task] install packages: openssl nginx OK
push [task] disable $service service [plg] service-dev OK
push [task] stopping $service service [plg] service-dev OK
push [task] starting $service service [plg] service-dev OK
push [task] enable $service service [plg] service-dev OK
copied SPL file as /opt/sparrow/sparrow.list - OK
get index updates from SparrowHub ... OK
set up task box file - /tmp/sparrowdo/task-box19964.json - OK
public@package-generic is uptodate (0.3.2)
installing private@service-dev ...
Already up-to-date.
running task box from /tmp/sparrow-cache/task-box19964.json ... 

@ package installer
•[task] install packages: openssl nginx at 2017-06-24 00:05:31
[path] modules/pacman/
[params] action:install package:openssl
trying to install openssl ...
installer - pacman
ok Installed
ok  scenario succeeded
ok  text has 'ok Installed'
•[task] install packages: openssl nginx at 2017-06-24 00:05:31
[path] modules/pacman/
[params] action:install package:nginx
trying to install nginx ...
installer - pacman
ok Installed
ok  scenario succeeded
ok  text has 'ok Installed'
STATUS  SUCCEED

@ linux service manager
•[task] disable $service service [plg] service-dev at 2017-06-24 00:05:31
[path] modules/disable/
[params] os:archlinux service:nginx
os: archlinux
service: nginx
done
ok  scenario succeeded
ok  text has 'done'
STATUS  SUCCEED

@ linux service manager
•[task] stopping $service service [plg] service-dev at 2017-06-24 00:05:32
[path] modules/stop/
[params] os:archlinux service:nginx
os: archlinux
service: nginx
* nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2017-06-23 23:46:35 AEST; 18min ago

Jun 23 23:46:35 archlinux.vagrant.vm systemd[1]: Starting A high performance web server and a reverse proxy server...
Jun 23 23:46:35 archlinux.vagrant.vm nginx[1372]: /usr/bin/nginx: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
Jun 23 23:46:35 archlinux.vagrant.vm systemd[1]: nginx.service: Control process exited, code=exited status=127
Jun 23 23:46:35 archlinux.vagrant.vm systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jun 23 23:46:35 archlinux.vagrant.vm systemd[1]: nginx.service: Unit entered failed state.
Jun 23 23:46:35 archlinux.vagrant.vm systemd[1]: nginx.service: Failed with result 'exit-code'.
 {nginx} stopped
ok  scenario succeeded
ok  text has '{nginx} stopped'
STATUS  SUCCEED

@ linux service manager
•[task] starting $service service [plg] service-dev at 2017-06-24 00:05:32
[path] modules/start/
[params] os:archlinux service:nginx
os: archlinux
service: nginx
* nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2017-06-24 00:05:33 AEST; 4ms ago
  Process: 3930 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; error_log stderr; (code=exited, status=0/SUCCESS)
 Main PID: 3932 (nginx)
    Tasks: 3 (limit: 4915)
   CGroup: /system.slice/nginx.service
           |-3932 nginx: master process /usr/bin/nginx -g pid /run/nginx.pid; error_log stderr;
           `-3933 nginx: worker process

Jun 24 00:05:32 archlinux.vagrant.vm systemd[1]: Starting A high performance web server and a reverse proxy server...
Jun 24 00:05:33 archlinux.vagrant.vm systemd[1]: Started A high performance web server and a reverse proxy server.
{nginx} running
ok  scenario succeeded
ok  text has '{nginx} running'
STATUS  SUCCEED

@ linux service manager
•[task] enable $service service [plg] service-dev at 2017-06-24 00:05:33
[path] modules/enable/
[params] os:archlinux service:nginx
os: archlinux
service: nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service -> /usr/lib/systemd/system/nginx.service.
done
ok  scenario succeeded
ok  text has 'done'
STATUS  SUCCEED
melezhik commented 7 years ago

выложил на SPH