Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp90023-assignment-2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matthew O'Halloran
comp90023-assignment-2
Commits
d752a1cd
Commit
d752a1cd
authored
5 years ago
by
advait22
Browse files
Options
Downloads
Patches
Plain Diff
fixed server start issue
parent
4ab159ef
Branches
Branches containing commit
No related tags found
1 merge request
!8
fixed server start issue
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ansible/roles/react-build/tasks/main.yaml
+35
-33
35 additions, 33 deletions
ansible/roles/react-build/tasks/main.yaml
with
35 additions
and
33 deletions
ansible/roles/react-build/tasks/main.yaml
+
35
−
33
View file @
d752a1cd
...
...
@@ -8,7 +8,7 @@
become
:
yes
apt
:
name
:
[
'
nodejs'
,
'
npm'
]
state
:
lates
t
state
:
presen
t
install_recommends
:
no
update_cache
:
yes
-
debug
:
...
...
@@ -20,15 +20,7 @@
npm
:
name
:
npm
global
:
yes
state
:
latest
-
name
:
install pm2 server
tags
:
'
pm2'
become
:
yes
npm
:
name
:
pm2
global
:
yes
state
:
latest
state
:
present
-
name
:
install react
tags
:
'
react'
...
...
@@ -71,13 +63,6 @@
msg
:
'
inside
server'
when
:
server.rc == 0
-
name
:
install dependencies
become
:
yes
command
:
npm install --save express
-
debug
:
msg
:
'
Client
express
installed'
when
:
server.rc ==
0
-
name
:
change working directory to the client
become
:
yes
shell
:
cd
...
...
@@ -94,7 +79,6 @@
msg
:
'
Client
Dependencies
installed'
when
:
client.rc ==
0
-
name
:
Ansible check directory exists build in client.
stat
:
path
:
/var/lib/react/express_react_example/client/build
...
...
@@ -112,7 +96,6 @@
###workaround for react js bug in build command
-
name
:
delete dependencies on client
become
:
yes
shell
:
rm -rf node_modules
...
...
@@ -131,6 +114,14 @@
register
:
cache_cleaned
when
:
deleted_modules.rc ==
0
-
name
:
install dependencies
become
:
yes
npm
:
path
:
/var/lib/react/express_react_example/
name
:
express
-
debug
:
msg
:
'
Client
express
installed'
-
name
:
install dependencies
become
:
yes
npm
:
...
...
@@ -165,12 +156,12 @@
path
:
/var/lib/react/express_react_example/build
register
:
files_to_delete_from_server
-
name
:
delete previous build folder in server
become
:
yes
shell
:
rm -rf build
args
:
chdir
:
/var/lib/react/express_react_example/
warn
:
false
register
:
build_delete_server
-
debug
:
msg
:
"
deleting
old
build
from
server"
...
...
@@ -184,18 +175,29 @@
msg
:
'
build
copied'
when
:
build_delete_server.rc ==
0
-
name
:
stop all the running server
-
name
:
"
Install
forever
(to
run
Node.js
app)."
become
:
yes
npm
:
name
:
forever
global
:
yes
state
:
present
-
name
:
"
Check
list
of
Node.js
apps
running."
become
:
yes
command
:
forever list
register
:
forever_list
changed_when
:
false
-
name
:
stop if the server is running
become
:
yes
command
:
pm2 stop all
register
:
stop_server
command
:
forever stopall
-
debug
:
msg
:
'
all
server
s
stopped
'
#
when:
build_copy.rc == 0
msg
:
"
server
stopped
"
when
:
forever_list.stdout.find('/var/lib/react/express_react_example/server.js') == "336"
-
name
:
s
tart
the server
-
name
:
"
S
tart
react.js
app."
become
:
yes
# command: node /var/lib/react/express_react_example/server.js &
command
:
pm2 start /var/lib/react/express_react_example/server.js
command
:
forever start /var/lib/react/express_react_example/server.js
-
debug
:
msg
:
'
yayyyyyyyyyyy
app
is
running'
# when: stop_server.rc == 0
\ No newline at end of file
msg
:
"
server
started"
when
:
forever_list.stdout.find('/var/lib/react/express_react_example/server.js') == -1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment