Ruby on Rails app transfer to webserver fails - ruby-on-rails

I have made the GoRails https://gorails.com/deploy/ubuntu/20.04 tutorial. Everything installed. But now I can not transfer my app from the Mac to the Linux web server. The following error with probably git appears. What can I do?
cap production deploy
00:00 git:wrapper
01 mkdir -p /tmp
✔ 01 deploy#192.168.1.140 0.056s
Uploading /tmp/git-ssh-f9a2d67df5286b2a1eed.sh 100.0%
02 chmod 700 /tmp/git-ssh-f9a2d67df5286b2a1eed.sh
✔ 02 deploy#192.168.1.140 0.013s
00:00 git:check
01 git ls-remote git#github.com:mgasche/planer.git HEAD
✔ 01 deploy#192.168.1.140 1.065s
00:01 deploy:check:directories
01 mkdir -p /home/deploy/planer/shared /home/deploy/planer/releases
✔ 01 deploy#192.168.1.140 0.013s
00:01 deploy:check:linked_dirs
01 mkdir -p /home/deploy/planer/shared/log /home/deploy/planer/shared/tmp/pids /home/deploy/planer/shared/tmp/cache /home/deploy/planer/shared/tmp/sockets /home/deploy/plan…
✔ 01 deploy#192.168.1.140 0.052s
00:01 git:clone
The repository mirror is at /home/deploy/planer/repo
00:01 git:update
01 git remote set-url origin git#github.com:mgasche/planer.git
✔ 01 deploy#192.168.1.140 0.058s
02 git remote update --prune
02 Fetching origin
✔ 02 deploy#192.168.1.140 1.190s
00:02 git:create_release
01 mkdir -p /home/deploy/planer/releases/20220501182040
✔ 01 deploy#192.168.1.140 0.058s
02 git archive master | /usr/bin/env tar -x -f - -C /home/deploy/planer/releases/20220501182040
02 fatal: not a valid object name: master
02 tar: This does not look like a tar archive
02 tar:
02 Exiting with failure status due to previous errors

Beside the content (commits or empty repository), don't forget that a repository now (since Oct. 2020) has by default a main branch, not a master branch.
Make sure your git archive command takes into account the branch you need.

Related

Debian Docker on Mac M1Pro Monterey: cannot open shared object file: No such file or directory

I have a Docker container, that runs the redis:6 image, which builds FROM debian:bullseye-slim. When starting the redis server, I load a shared object file as a module, called redisearch.so. On my new Mac M1Pro Monterey this fails, telling me the file does not exist, even though it clearly does. I have checked that the file is there and made sure the permission is 777 and ownership is root.
On my old mac and another Linux device it runs fine.
Does anyone have a clue what could be the problem here?
Dockerfile
############ COMPILING OUR REDISSEARCH EXTENSION
FROM debian:buster-slim AS builder
RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y libatomic1
RUN apt-get install -y cmake
WORKDIR /home
RUN git clone https://github.com/RediSearch/RediSearch.git
WORKDIR /home/RediSearch
RUN rm ./tests/ctests/ext-example/*
COPY ./redisearch-ext/ ./tests/ctests/ext-example/
WORKDIR ./tests/ctests/ext-example/
RUN make jurata_extension.so
############ GETTING THE REDISEARCH SHARED OBJECT FILE AND PUTTING IT ON A REDIS SERVER
# Openshift compatible version of redissearch
FROM redislabs/redisearch:1.6.14 as redisearch
FROM redis:6
# ENV LD_LIBRARY_PATH /usr/lib/redis/modules
RUN apt-get update
RUN apt-get install -y sudo
COPY --from=redisearch /usr/lib/redis/modules/redisearch.so /usr/lib/redis/modules/
COPY --from=builder home/RediSearch/tests/ctests/ext-example/jurata_extension.so ./
COPY --from=builder home/RediSearch/tests/ctests/ext-example/jurata_extension.so /usr/lib/redis/modules/
ADD container-entrypoint.sh /
EXPOSE 6379
CMD ls -l /usr/lib/redis/modules/redisearch.so; sudo /usr/local/bin/redis-server --loadmodule /usr/lib/redis/modules/redisearch.so
Log Output
-rwxr-xr-x 1 root root 8531584 Sep 6 2020 /usr/lib/redis/modules/redisearch.so
10:C 04 Nov 2021 10:01:02.540 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10:C 04 Nov 2021 10:01:02.540 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=10, just started
10:C 04 Nov 2021 10:01:02.540 # Configuration loaded
10:M 04 Nov 2021 10:01:02.540 * monotonic clock: POSIX clock_gettime
10:M 04 Nov 2021 10:01:02.540 * Running mode=standalone, port=6379.
10:M 04 Nov 2021 10:01:02.540 # Server initialized
10:M 04 Nov 2021 10:01:02.541 # Module /usr/lib/redis/modules/redisearch.so failed to load: /usr/lib/redis/modules/redisearch.so: cannot open shared object file: No such file or directory
10:M 04 Nov 2021 10:01:02.541 # Can't load module from /usr/lib/redis/modules/redisearch.so: server aborting

Docker (node:8.15-alpine) + Chromium + Karma unit tests not working

I'm trying to run my frontend tests on Docker (node:8.15-alpine) using Chromium and Karma, however I'm getting lots of ChromeHeadless related errors.
These tests used to work but recently they suddenly stopped, so I'm guessing it's either related to a third-party dependency (apk?), or the local Docker install.
I've created a branch on the repo with an easy to run command which reproduces the issue. README.md here:
https://github.com/olivercaine/react-redux-starter-kit-extended/tree/bug/cant-run-unit-tests-in-docker
Any help with this would be masively appreciated!
Thanks.
Expected Outcome:
[output of passed tests...]
Finished in 0.026 secs / 0.031 secs # 19:53:44 GMT+1100 (AEDT)
SUMMARY:
✔ 46 tests completed
Actual Outcome:
13 02 2020 09:10:45.314:ERROR [launcher]: Cannot start ChromeHeadless
13 02 2020 09:10:45.316:ERROR [launcher]: ChromeHeadless stdout:
13 02 2020 09:10:45.317:ERROR [launcher]: ChromeHeadless stderr:
13 02 2020 09:10:45.772:ERROR [launcher]: Cannot start ChromeHeadless
13 02 2020 09:10:45.772:ERROR [launcher]: ChromeHeadless stdout:
13 02 2020 09:10:45.773:ERROR [launcher]: ChromeHeadless stderr:
13 02 2020 09:10:45.939:ERROR [launcher]: Cannot start ChromeHeadless
13 02 2020 09:10:45.939:ERROR [launcher]: ChromeHeadless stdout:
13 02 2020 09:10:45.939:ERROR [launcher]: ChromeHeadless stderr:
13 02 2020 09:10:46.424:ERROR [launcher]: ChromeHeadless failed 2 times (cannot start). Giving up.
Finished in 0 secs / 0 secs # 09:10:46 GMT+0000 (UTC)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-redux-starter-kit#3.0.1 test: `cross-env NODE_ENV=test karma start build/karma.config`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-redux-starter-kit#3.0.1 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-02-13T09_10_46_935Z-debug.log
Update:
The above URL has been removed, however the full (now working) repo can be found here:
https://github.com/olivercaine/react-redux-starter-kit-extended/tree/modpack/latest
It seems there are some issues regarding the node:8-alpine image that you are using. See https://github.com/puppeteer/puppeteer/issues/379. I don't know if it's the same issue but I was able to run your tests using the node:8.15-slim as the base image of your base Dockerfile
You'll need to update your dev Dockerfile as well:
FROM olliecaine/base:master
WORKDIR /project
# Install Chrome
RUN apt update && apt install -y chromium
Ideally you would add ENV CHROME_BIN=/usr/bin/chromium to this Dockerfile, but for some reason this is not setting the variable properly.
To check that yourself, and insert console.log(process.env.CHROME_BIN) at the beginning of your build/karma.config.js file, you will see the value is still /usr/bin/chromium-browser when running the tests.
As a workaround, I had to insert this line at the beginning of the build/karma.config.js file:
process.env.CHROME_BIN = '/usr/bin/chromium'
Let me know if you understand why the ENV instruction is not working, I'm interested.
Thanks Baptiste, your answer helped me verify the fix was working.
Basically what I ended up doing was using a different URL for alpinelinux.org.
In the end I changed the Dockerfile to:
FROM node:8.15-alpine
WORKDIR /project
# Install Chrome
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
&& echo http://dl-cdn.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
&& echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories \
&& apk --no-cache update && apk --no-cache upgrade \
&& apk add --no-cache chromium \
&& rm -rf /var/cache/apk/* /tmp/*
ENV CHROME_BIN /usr/bin/chromium-browser
which seemed to set the CHROME_BIN env variable properly, allowing me to run my tests in the Alpine container. Also meant I didn't need to update the karma.config.js file either. Previously I was using nl.alpinelinux.org/alpine/v3.8/ instead of edge.
Cheers for your help!

Phusion Passenger is running as root, and part(s) of the Passenger root path () can be changed by non-root user(s)

[Thu Jul 05 07:58:30.268108 2018] [core:warn] [pid 7157] AH00117: Ignoring deprecated use of DefaultType in line 111 of /usr/local/apache/conf/httpd.conf.
[Thu Jul 05 07:58:30.268302 2018] [alias:warn] [pid 7157] AH00671: The Alias directive in /usr/local/apache/conf/httpd.conf at line 318 will probably never match because it overlaps an earlier Alias.
[Thu Jul 05 07:58:30.270866 2018] [:notice] [pid 7157] HiveEXEC mechanism enabled (wrapper: /usr/local/1h/sbin/hive_exec)
[Thu Jul 05 07:58:30.276835 2018] [:notice] [pid 28647] FastCGI: process manager initialized (pid 28647)
[ N 2018-07-05 07:58:30.2928 28649/T1 age/Wat/WatchdogMain.cpp:1297 ]: Starting Passenger watchdog...
[ N 2018-07-05 07:58:30.3078 28652/T1 age/Cor/CoreMain.cpp:1202 ]: Starting Passenger core...
[ N 2018-07-05 07:58:30.3079 28652/T1 age/Cor/CoreMain.cpp:252 ]: Passenger core running in multi-application mode.
[ W 2018-07-05 07:58:30.3242 28652/T1 age/Cor/CoreMain.cpp:929 ]: **WARNING: potential privilege escalation vulnerability detected. Phusion Passenger is running as root, and part(s) of the Passenger root path (/usr/local/rvm/gems/ruby-2.4.1#myspace_new/gems/passenger-5.3.2) can be changed by non-root user(s):**
- /usr/local/rvm/gems/ruby-2.4.1#myspace_new/gems is not secure: it can be modified by group rvm
- /usr/local/rvm/gems is not secure: it can be modified by group rvm
Please either fix up the permissions for the insecure paths, or install Passenger in a different location that can only be modified by root.
[ N 2018-07-05 07:58:30.3242 28652/T1 age/Cor/CoreMain.cpp:937 ]: Passenger core online, PID 28652
[Thu Jul 05 07:58:30.327114 2018] [mpm_prefork:notice] [pid 7157] AH00163: Apache/2.4.29 (Unix) mod_hive/6.6 OpenSSL/1.0.1e-fips mod_fastcgi/2.4.6 Phusion_Passenger/5.3.2 configured -- resuming normal operations
[Thu Jul 05 07:58:30.327141 2018] [core:notice] [pid 7157] AH00094: Command line: '/usr/local/apache/bin/httpd -D SSL'
[ N 2018-07-05 07:58:30.5457 27311/T1 age/Cor/CoreMain.cpp:1187 ]: **Passenger core shutdown finished**
The answer, for me :
1 -
For the website in /opt/redmine/redmine-site-version
sudo chown www-data:redmine-user -R /opt/redmine/
2 -
cd /opt
sudo chown root:root redmine/
cd /opt/redmine
sudo chown root:root .rvm/
cd /opt/redmine/.rvm
sudo chown root:root gems/
cd /opt/redmine/.rvm/gems
sudo chown root:root ruby-2.4.5#redmine-4.0-stable-prod-unis
cd /opt/redmine/.rvm/gems/ruby-2.4.5#redmine-4.0-stable-prod-unis
sudo chown root:root gems/
cd /opt/redmine/.rvm/gems/ruby-2.4.5#redmine-4.0-stable-prod-unis/gems
sudo chown root:root passenger-6.0.2
Restart Apache2
Look your logs.
Redmine RVM 2020 : https://wiki.visionduweb.fr/index.php?title=Installer_Redmine_sur_Debian_avec_RVM#Notes_de_s.C3.A9curit.C3.A9

Cron jobs not executing command

I'm trying to schedule backups using cron jobs as explained here.
The cron jobs do run but sadly don't execute the command inside it.
This is my schedule.rb file
every 1.minute do
command "backup perform -t my_backup"
end
Which translates to this cron file:
# Begin Whenever generated tasks for: /home/roy/Backup/config/schedule.rb
* * * * * /bin/bash -l -c 'backup perform -t my_backup'
# End Whenever generated tasks for: /home/roy/Backup/config/schedule.rb
The cron jobs then run every minute (I can see that by running grep CRON /var/log/syslog). These are my last cron jobs:
Mar 20 21:48:01 roybuntu CRON[18041]: (roy) CMD (/bin/bash -l -c 'backup perform -t my_backup')
Mar 20 21:48:01 roybuntu CRON[18040]: (roy) MAIL (mailed 37 bytes of output but got status 0x004b from MTA#012)
Mar 20 21:49:01 roybuntu CRON[18063]: (roy) CMD (/bin/bash -l -c 'backup perform -t my_backup')
Mar 20 21:49:01 roybuntu CRON[18062]: (roy) MAIL (mailed 37 bytes of output but got status 0x004b from MTA#012)
I also installed postfix because earlier I got "No MTA installed" error messages in the example above. However this didn't fix it.
Anyone familiar with this problem and/or know how to fix it?
EDIT:
Also running the cron file as a root user doesn't seem to work. I used sudo crontab -e to edit the root cron file.
This is the output when running the grep CRON /var/log/syslog command after I added a root crontab:
Mar 21 19:36:01 roybuntu CRON[9387]: (root) CMD (/bin/bash -l -c 'backup perform -t my_backup')
Mar 21 19:36:01 roybuntu CRON[9388]: (roy) CMD (/bin/bash -l -c 'backup perform -t my_backup')
Mar 21 19:36:01 roybuntu CRON[9385]: (roy) MAIL (mailed 37 bytes of output but got status 0x004b from MTA#012)
Mar 21 19:36:01 roybuntu CRON[9386]: (root) MAIL (mailed 90 bytes of output but got status 0x004b from MTA#012)
Did you try running the cron task command as the same user as your application? It may not have the permission to run that command.

Whenever ruby on rails

In my schedule:
every 10.minutes do
runner "Model.method"
end
Whenever created this in my crontabs
0,10,20,30,40,50 * * * * /bin/bash -l -c 'cd /home/projects/Monitoring && script/rails runner -e development '\''Model.method'\'''
I tried to run the command in my console and it works. Why does it not work automaticly, i am going insane!
In my syslog
Mar 11 11:38:01 UbuntuRails CRON[20050]: (ruben) CMD (/bin/bash -l -c 'cd /home/projects/Monitoring && script/rails runner -e development '\''Ping.check_pings'\''')
Mar 11 11:38:01 UbuntuRails CRON[20048]: (CRON) info (No MTA installed, discarding output)
Mar 11 11:38:01 UbuntuRails CRON[20047]: (CRON) error (grandchild #20050 failed with exit status 1)
Mar 11 11:38:01 UbuntuRails CRON[20047]: (CRON) info (No MTA installed, discarding output)
I am on Ubuntu 10.10 and had the same problem.
Turns out the -l option does not load the environment as expected, but -i does. (see this issue)
As the issue thread states, the fix is to edit your schedule.rb and add:
set :job_template, "/bin/bash -i -c ':job'"
Cheers

Resources